How to add "choose a scale"

469
1
10-13-2011 07:24 AM
NathalieLambert
New Contributor II
Hi,

I'm writing a web application with the Javascript API.

I'd like to add the possibility to the user to choose the scale he want to see data.

In the sample, I've only see sample of scalebar, which is not what I'd like to do.

Does somebody knows where I can find a sample of this functionality?

Regards,

Nathalie
0 Kudos
1 Reply
HemingZhu
Occasional Contributor III
Hi,

I'm writing a web application with the Javascript API.

I'd like to add the possibility to the user to choose the scale he want to see data.

In the sample, I've only see sample of scalebar, which is not what I'd like to do.

Does somebody knows where I can find a sample of this functionality?

Regards,

Nathalie


I don't think API provide this functionality directly. However it should be relatively easy to implement this functionality. Here are my thoughts. Create a dropdown and populate the scales. if your map contains ArcGISTiledMapServiceLayer, get scales and levels in the following:
ArcGISTiledMapServiceLayer -> tileInfo ->lods->lod (lod.level and lod.scale). Once user pick up a scale, get the level corrspondent to that scale and use map.setLevel(level) to zoom to that scale. If you map does not contains tiledlayer, you can populate dropdown with the scales you defined, once user pick up a scale, you could use map.centerAndZoom( map.extent.getCenter(), pickedScale/esri.geometry.getScale(map)) to zoom to pickedScale. Hope it will help
0 Kudos