Select to view content in your preferred language

pan doesn't work

2602
6
11-18-2010 06:41 AM
ThaoNguyen
Emerging Contributor
My map is added as following (I just make it simple, I know that I have multiple stackpanel, but cannot remove...)
<StackPanel>
   <StackPanel>
        <Grid><esriMap/></Grid>
   </StackPanel>
</StackPanel>

After the map is drawn, pan function doesn't work.  I googled and tried to remove ScrollViewer, set Horizontal and Vertical Aligments to "non-stretch".  It still doesn't work.  Is there any suggestions?

Thank you so much!!
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
Make sure that there are no element overlaps your map. I've seen this happen a few times even if the element overlapping is Transparent, as long as its IsHitTestVisible is true - no mouse events will be raised on the element behind it.
0 Kudos
ThaoNguyen
Emerging Contributor
Make sure that there are no element overlaps your map. I've seen this happen a few times even if the element overlapping is Transparent, as long as its IsHitTestVisible is true - no mouse events will be raised on the element behind it.


What you meant by "overlapping" was an element is on top of the map, right?  If so, I don't have anything, I only have have the map.  I even set the map IsHitTestVisible to true and I can see the value of true BEFORE I set it (while debugging).
0 Kudos
JenniferNery
Esri Regular Contributor
You verified nothing similar to this, right? In this case, I did not mean to overlap the map with the grid but it's not apparent to me because visually, the element blocking the map is transparent. If you have something like this, you need to set IsHitTestVisible=false on the grid that overlapped your map.

    <Grid x:Name="LayoutRoot" Background="White" >
  <esri:Map x:Name="MyMap">
   <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
  </esri:Map>
  <Grid Background="Transparent" />    
 </Grid>


You mentioned that you no longer use ScrollViewer, right? Because if you still do, ScrollViewer intercepts the mouse events.

You can also check if any mouse events on the parent of the map are marked handled. If so, the mouse events will not be raised for the map.

For example:
    <Grid x:Name="LayoutRoot" Background="White" MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown">
 <esri:Map x:Name="MyMap">
  <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
 </esri:Map>
    </Grid>

 private void LayoutRoot_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
  e.Handled = true;
 }
0 Kudos
ThaoNguyen
Emerging Contributor
You verified nothing similar to this, right? In this case, I did not mean to overlap the map with the grid but it's not apparent to me because visually, the element blocking the map is transparent. If you have something like this, you need to set IsHitTestVisible=false on the grid that overlapped your map.

    <Grid x:Name="LayoutRoot" Background="White" >
  <esri:Map x:Name="MyMap">
   <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
  </esri:Map>
  <Grid Background="Transparent" />    
 </Grid>




--> I have the following, no background is set to transparent.  They all from SystemColors.
<StackPanel Background="system color here">
<Grid Background="color here">
<StackPanel Background="color here"><Map/>
</StackPanel>
</Grid>
</StackPanel>


You mentioned that you no longer use ScrollViewer, right? Because if you still do, ScrollViewer intercepts the mouse events.

You can also check if any mouse events on the parent of the map are marked handled. If so, the mouse events will not be raised for the map.

For example:
    <Grid x:Name="LayoutRoot" Background="White" MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown">
 <esri:Map x:Name="MyMap">
  <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
 </esri:Map>
    </Grid>

 private void LayoutRoot_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
  e.Handled = true;
 }


--> Correct, I removed all ScrollViewer.  No MouseLeftButton event implemented yet.
0 Kudos
JenniferNery
Esri Regular Contributor
The StackPanels are fine, they are guaranteed not to overlap elements contained within them.

But I would be cautious with the Grids. Even if you create Row/ColumnDefinitions if not all elements contained in the Grid are assigned their respective Grid.Row/Column, they may share the same space and overlap may occur.

In this example, the TextBlock will occupy the whole grid, blocking the map from getting any mouse event.
     <Grid x:Name="LayoutRoot" Background="White" >  
  <esri:Map x:Name="MyMap">
   <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
  </esri:Map>
  <TextBlock/>    
 </Grid>


Whether it's this:
(1): From post#5

<StackPanel Background="system color here"> 
<Grid Background="color here">
<StackPanel Background="color here"><Map/> 
</StackPanel> 
</Grid>
</StackPanel> 


or this:
(2) From post #1

<StackPanel> 
<StackPanel> 
<Grid><esriMap/></Grid>
</StackPanel> 
</StackPanel> 

you are doing - Check the other elements contained in the Grid, specifically elements defined after the map. Comment them out one by one until you figure out which of those overlap the map.

You can create a new project with only the map, you will see that pan works. So in your current app, pan does not work because either something intercepts the mouse events or map is not hit at all because some element is blocking it.
0 Kudos
ThaoNguyen
Emerging Contributor
The StackPanels are fine, they are guaranteed not to overlap elements contained within them.

But I would be cautious with the Grids.  Even if you create Row/ColumnDefinitions if not all elements contained in the Grid are assigned their respective Grid.Row/Column, they may share the same space and overlap may occur.

In this example, the TextBlock will occupy the whole grid, blocking the map from getting any mouse event.
     <Grid x:Name="LayoutRoot" Background="White" >  
  <esri:Map x:Name="MyMap">
   <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
  </esri:Map>
  <TextBlock/>    
 </Grid>


Whether it's this:
(1): From post#5


or this:
(2) From post #1

you are doing - Check the other elements contained in the Grid, specifically elements defined after the map. Comment them out one by one until you figure out which of those overlap the map.

You can create a new project with only the map, you will see that pan works. So in your current app, pan does not work because either something intercepts the mouse events or map is not hit at all because some element is blocking it.


I don't have anything else in the Grid except the map :(.  I will look closely again in case I tested something and forgot to remove.  Thanks!
0 Kudos