"Fake" a zoom level with Google Maps MapCanvasProjection
I'm using a google.maps.MapCanvasProjection
to calculate some things about a map (using fromLatLngToContainerPixel
) right before it's about to be panned and zoomed to a new location. Here's how I get the projection:
var overlay = new google.maps.OverlayView();
overlay.draw = function(){};
overlay.setMap(map);
var proj = overlay.getProjection();
However, the calculations I need to make using this overlay need to be based on the position and zoom level of the map after it's been zoomed, since it uses pixel widths that won't be accurate once the zoom level changes. I have a function I wrote called getZoomLevel()
that returns the future zoom level I'll need, but I can't figure out how to create a "virtual map" with this new zoom level. I want to make these calculations before the actual, visible map is moved or zoomed in any way.
Short of creating an entirely new map that's never added to the DOM, is there a way to make fromLatLngToContainerPixel
assume a different zoom level than the zoom of the currently visible map?
Working, but hackish example: http://hamclock.net/maps/
链接地址: http://www.djcxy.com/p/81574.html上一篇: 如何在谷歌地图中设置缩放级别