How can I select the portion in Map in Rectangle box and zoom it?

1214
5
Jump to solution
11-29-2016 08:51 PM
AmatyaGupta
New Contributor II

How can I select the portion in Map in Rectangle box and zoom it?

 Thanks in advance

0 Kudos
1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

So you want to draw a rectangle to select data and zoom to the selection or just zoom by rectangle?

Have you looked at the RubberBandZoom property of the map? Map | API Reference | ArcGIS API for JavaScript 3.18 

View solution in original post

5 Replies
FC_Basson
MVP Regular Contributor

Are you working with a Feature Service or a Dynamic Map service layer? You will first need to create an event listener on the layer to determine if the user has clicked on the layer.  Depending on the layer type, you must define the function for the layer click event - for Feature Layer you can use the geometry of the graphic feature directly and for Dynamic Services you probably need to do an Query or Identify Task (IdentifyTask | API Reference | ArcGIS API for JavaScript 3.18 ) first to retrieve the feature geometry.  Then only can you use the map's setExtent function (Map | API Reference | ArcGIS API for JavaScript 3.18 ) to zoom to the extent of the portion

map.setExtent(esri.graphicsExtent([clickGraphic]))‍‍

.

AmatyaGupta
New Contributor II

Iam not able to select the map via rectangle box. How can I do that?

 I have done fullExtent through the below code:

map.setExtent(dynamicMapServiceLayer.fullExtent);

 Now I want to make a tool through as i select the portion of map it should zoom.

Plzz reply as soon as possible.

Thanks in Advance

0 Kudos
FC_Basson
MVP Regular Contributor

So you want to draw a rectangle to select data and zoom to the selection or just zoom by rectangle?

Have you looked at the RubberBandZoom property of the map? Map | API Reference | ArcGIS API for JavaScript 3.18 

AmatyaGupta
New Contributor II

I got it brother.. Thanks for your time.

0 Kudos
AmatyaGupta
New Contributor II

Thanks FC Basson bro .. I got it.

0 Kudos