javascript - How to get max zoom for maptype in location -
on google maps' js api reference page, says method getmaxzoomatlatlng
:
returns maximum zoom level available @ particular latlng satellite map type.
for reason, terrain maptype bottoms out @ level 15 in calgary (for example) satellite maptype can go way zoom 19. have 2 map services running simulataneously, , want maps in sync, can't sync if can't reach same zoom level.
so, i want know when terrain map (or maptype) can't cope, , trigger special case functions.
is there method, or alternative, getting maximum zoom location specific map type (since above mentioned method works satellite)?
well, 1 solution i've decided go in meantime attach zoom-end
handler arcgis map (could leaflet well) , maptypeid_changed
handler google map.
so, arcgis map (emap
) did this:
emap.on('zoom-end', function (e) { // map zooms synced gmap.setcenter(esri.geometry.webmercatortogeographic(e.extent.getcenter())); gmap.setzoom(e.level); // if google map couldn't it, reset emap if (gmap.getzoom() !== e.level) { emap.setzoom(gmap.getzoom()); // runs handler again } });
and if google map set satellite, changed, needed trigger same check, forced execute zoomend handler:
google.maps.event.addlistener(gmap, 'maptypeid_changed', function () { // reason, esri has issues setting zoom current zoom // has run initial check before calling zoomend if (gmap.getzoom() !== emap.getzoom()) { emap.setzoom(gmap.getzoom()); } });
hope helps someone, really, i'm looking forward seeing better solution this. seems awfully complicated approach merely firing function if google's maptype can't reach zoom level.
Comments
Post a Comment