Select to view content in your preferred language

How do I zoom to a specific scale programmatically?

1528
3
Jump to solution
12-17-2013 11:21 AM
YohanBienvenue
Frequent Contributor
Hi,

I modified the CoordinateWidget so that the current scale value of the map is displayed in the lower left corner of the map.

[ATTACH=CONFIG]29949[/ATTACH]

However I don't just need to see it, I want the user to be able to specify the scale too.
Which is why I made the scale displayed in a TextInput.

I thought there would be a simple function in the API to let me zoom the map by passing a specific scale, but I didn't find one.
It has to be possible since the API Navigator component (com.esri.ags.components.Navigation) does it with the LODs specified in the config.xml.

Anyone already did something like this?

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Honored Contributor
Yohan,

Just use map.scale

Regards

Anthony

View solution in original post

0 Kudos
3 Replies
AnthonyGiles
Honored Contributor
Yohan,

Just use map.scale

Regards

Anthony
0 Kudos
YohanBienvenue
Frequent Contributor
Ok this works.
I already use map.scale to get the value, didn't realize I could use this property to set the scale instead of going through a setter.

If I use this solution though, I'll have to get it rid of the LODs in the config.xml, otherwise it just scales to the closest LOD instead of the entered value.

We don't use tiles cache so we don't really need the LODs, but without them the Navigator widget will not have a zoom slider, which the users kind of like (instead of just the - and + zoom buttons).

Wish I could have both, but will settle for no LOD if it's not possible.

Thanks Anthony.
0 Kudos
AnthonyGiles
Honored Contributor
Yohan,

You could use a combobox instead of a text box and have your scales hard coded, or read in from from the widget xml file.

Fire the map.scale on change of the combobox value

Regards

Anthony
0 Kudos