Select to view content in your preferred language

Zoom to Query Result

791
5
12-31-2012 05:36 AM
BrianLeroux
Frequent Contributor
I am trying to zoom to the results of a query which is added to my map as a graphics layer. I have been trying numerous ways to get the map to zoom to that layer but can't get it to work. Once the layer is added I have no issues with using the Go To buton to zoom into the layer. I am missing something but I am not sure what. Here is a sample of one way I was trying to accomplish this.
string layerID = "Policy";
 Layer zoomlayer = MapApplication.Current.Map.Layers[layerID];
 MapApplication.Current.Map.ZoomTo(zoomlayer.FullExtent.Extent);
0 Kudos
5 Replies
BrianLeroux
Frequent Contributor
PanTo works with this but ZoomTo does not. ??

MapApplication.Current.Map.PanTo(zoomlayer.FullExtent.Extent);.
0 Kudos
KarenEllett
Regular Contributor
Have you tried something like this:

MapApplication.Current.Map.Extent = zoomLayer.FullExtent;
0 Kudos
BrianLeroux
Frequent Contributor
Have you tried something like this:

MapApplication.Current.Map.Extent = zoomLayer.FullExtent;


This did not work. Map extent remained the same.
0 Kudos
YurongTan
Regular Contributor
NEVER MIND.  I FOUND IT.

Based on your suggestion, "MapApplication.Current.Map.PanTo(zoomlayer.FullExtent.Extent);", I am unable to see "Current" under MapApplication nor "Map" after "Current", what do I miss?  Thanks

ESRIStandardMapApplication1.App.Current.Map.PanTo(graphicOHI.FullExtent.Extent);

Error message:
'System.Windows.Application' does not contain a definition for 'Map' and no extension method 'Map' accepting a first argument of type 'System.Windows.Application' could be found (are you missing a using directive or an assembly reference?) C:\Staging\_PROJECTS\ESRIStandardMapApplication1\ESRIStandardMapApplication1\MainPage.xaml.cs 291 65 ESRIStandardMapApplication1
0 Kudos
JohanCarlsson
Regular Contributor
You have pointed to the wrong assembly.
This is the full path to the map:
ESRI.ArcGIS.Client.Extensibility.MapApplication.Current.Map
0 Kudos