-1

In OpenLayers 3.9.0 .I have default scale for OpenLayers 3 but what user want is able to set the scale like 1:2000 or 1:5000 and so on using a drop down select box.

something like the image below.

enter image description here

  • You can create a custom control. – Jonatas Walker Sep 24 '15 at 9:27
  • any idea where to start. I looked up i found resolution but how can i extract scale from resolution. what is the relation in between scale, resolution and zoom level ? – Abhijit Gujar Sep 24 '15 at 12:51
  • Well, if @ThomasB solution suits to you, great, if you want an extended ol.control.Control like this, then there's a little work ahead. – Jonatas Walker Sep 24 '15 at 16:25
2

To get the current Scale I found this answer in Google Groups: https://groups.google.com/forum/#!msg/ol3-dev/RAJa4locqaM/Tg-JQ9L_YeMJ

Another useful part can be found here: https://github.com/bartvde/geoserver-ol3-preview/blob/master/index-ol3.html (the section starting with "map.getView().on('change:resolution', ..." )

I set up a working example here: http://jsfiddle.net/expedio/ks9t826k/

As the API of ol3 is still changing a lot I am still working much more with OpenLayers2. Perhaps someone who is already a bit more familiar with ol3 can have a look at this jsfiddle and tell if there is a better solution than this ;)

  • looks promising, I will get back after trying it . Thanks Thomas B. – Abhijit Gujar Sep 24 '15 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.