Select to view content in your preferred language

Easy way to set the resolution to include all items on a GraphicsLayer

1099
2
Jump to solution
01-17-2012 10:19 AM
TylerRothermund
Emerging Contributor
When the user clicks on a marker I add new items to a map that might be outside of the current extent.   Is there an easy way to set the resolution to the smallest value that will still display all the items that have been drawn on a GraphicsLayer?
0 Kudos
1 Solution

Accepted Solutions
DaveTimmins
Deactivated User
Hi,

have you tried calling the ZoomTo method of the map with the full extent of the graphics layer?

var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; MyMap.ZoomTo(graphicsLayer.FullExtent);


Cheers,

View solution in original post

0 Kudos
2 Replies
DaveTimmins
Deactivated User
Hi,

have you tried calling the ZoomTo method of the map with the full extent of the graphics layer?

var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; MyMap.ZoomTo(graphicsLayer.FullExtent);


Cheers,
0 Kudos
TylerRothermund
Emerging Contributor
Hi,

have you tried calling the ZoomTo method of the map with the full extent of the graphics layer?

var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
MyMap.ZoomTo(graphicsLayer.FullExtent);


Cheers,



Thanks, thats what I was needed. 
My markers are 125px wide and the top right corner is placed on the x/y cordinate, so I ended up using this to make sure the entire marker was visible
I had to use some trial an error on the +/- but it seems to work.

var e  = GraphicsLayer.FullExtent;
MyMap.Extent = new Envelope( e.XMin - 4, e.YMin - 1, e.XMax + 4 , e.YMax + 1);
0 Kudos