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.
<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>
<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;
}
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; }
<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>
<StackPanel Background="system color here">
<Grid Background="color here">
<StackPanel Background="color here"><Map/>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel>
<StackPanel>
<Grid><esriMap/></Grid>
</StackPanel>
</StackPanel>
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.