I've just setup a new project following this video http://youtu.be/R0l-7en3dUw.
I was wondering how can I set the map zoom level in a project like this.
I've looked at the src on github and since in map.coffee
there isn't something like zoomTo: (zoomLvl)-> @getServiceObject().setZoom(zoomLvl)
I don't have any idea how to do it. So can anyone help me?
I've tried this kind of solution as suggested here (zoom in to particular region in gmap4rails) but with any good result:
Gmaps.map.callback = function() {
google.maps.event.addListenerOnce(Gmaps.map.getMapObject(), 'idle', function(){
var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(10, 0), new google.maps.LatLng(0, 10));
Gmaps.map.serviceObject.panToBounds(bounds);
}
});
first you're mixing methods from v1 and v2. v2 arrived in october 2013, all previous answers wont be helpful.
Gmaps.map.callback
is from v1.
in v2, you can do:
#work directly with the google object:
handler.getMap().setZoom(zoom_level)
来源:https://stackoverflow.com/questions/19954579/how-to-set-a-zoom-level-using-gmap4rails