In this article I'm going to write about zoom to selected features if that features are in multiple layers. Almost every article I've seen deals with zoom to selected features in a single layer.
If you want to zoom to multiple features in a single layer ,
a. extract the fidset from the layer description
b. use that fidset in creating a new feature extent
featureExtent.FeatureIDs = FIDSet
featureExtent.layerID = LayerID
featureExtent.MapName = MapName
c. finally use WebMap.DrawExtent(featureExtent) method to zoom to the selected features which are in a single layer.
But this technique will not work if you are dealing with selected features in multiple layers (more than one layer)
Here we should use the whole set of selected features in different layers for zooming .. look at the following steps
a. The most commonly used way to implement zoom to selected features tool is using a seperate class file that implements the IMapServerToolAction interface.
b. When you implement the IMapServerToolAction, you should be able to access the rectangleEventArgs from the function ServerAction(ByVal args As ToolEventArgs).
Dim rectangleEventArgs As RectangleEventArgs = args
c. Store this rectangleEventArgs in ASP session
page.Session.Add("rectArgs",rectangleEventArgs)
d. For zoom to selected features I'm using the ESRI toolbox "command" .
e. Now in the action part of the command , first retrieve the rectangleEventArgs from the
ASP session
f. Create an envelope out of the WebMap and this rectangleEventArgs
Dim rectEnvelope As IEnvelope = Converter.ToMapEnvelope(webMap,
RectangleEventArgs.ScreenExtent)
g. Use this envelope to drawExtent.
Dim webimage As WebImage = webMap.DrawExtent(envelope)
webMap.Refresh()
Thats it..That will do the tick . If you have face any problems doing it , just mail me or leave a
comment here.
Addy.
Zoom to Selected features in Multiple Layers
Subscribe to:
Posts (Atom)