Вопрос

We try to restrict zoom out level of world map in my application and my application build on Ruby on rails 3.

We used "gmap4rails" gem for Google map but problem was world map will repeat multiple time on map area as you can see in attached image.

we required 3 section that will be good for user to visualization but if its 3,4 section then also its expectable but its repeat 5 time. please help us to restrict zoom out.

enter image description here

Это было полезно?

Решение 2

in gmap4rails we use minZoom and maxZoom option and its works for us below our code that we use thanks

= gmaps({"map_options" => {"auto_zoom" => false,"minZoom" => 2, "maxZoom" => 15,"zoom" => 2}, "markers" => {"data" => @latest_projects_json }})

Другие советы

Have you tried with the zoom_changed event ? This event is fired everything the zoom change, as you probably guessed it. So, the idea is to detect ah which zoom level your user is, and, if the zoom is < 3 for example, just force the zoom to stay at level 3. Something like :

google.maps.event.addListener(map, 'zoom_changed', function() {
    var zoomLevel = map.getZoom();
    if(zoomLevel < 3)
        map.setZoom(3);
});

Of course, you have to adapt it with your own situation. But I think this could be a good start. Feel free to ask if you need more precision.

You can also take a look at this question on SO , the OP's probelm is not really the same than yours, but some answers can help you.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top