根据您所在的缩放级别显示Google地图标记 [英] Show google map marker depending on what zoomlevel you're on
问题描述
我想知道是否可以将标记设置为在所选缩放级别中可见的
Google Map API v3。
我认为可以在v2该API使用标记管理器,但无法找到最新的API。
I'm wondering if it's possible to set markers to be visible in a chosen zoom level for the
Google Map API v3.
I figured it's possible in the v2 of the API using the "Marker Manager" but can't find a way for the latest API.
示例:
Marker-1 - >( max_zoom:10,min_zoom:5)//将在缩放级别5-10内显示
Marker-2 - >(max_zoom:15,min_zoom:10)//将在缩放级别内显示10-15
Example:
Marker-1 -> (max_zoom:10, min_zoom:5) //will on be shown within zoom level 5-10
Marker-2 -> (max_zoom:15, min_zoom:10) //will on be shown within zoom level 10-15
当我开发一个jQuery插件时,我只想使用原始API而无需附加组件。
As I'm developing an jQuery-plugin I only want to use the original API without add-ons.
预先感谢!
推荐答案
假设map是管理gmap的实例对象,我会做一些事情像这样:
Supposing map is the object instanced to manage the gmap, i'd do something like this:
var zoomLevel = map.getZoom();
if (zoomLevel>=5 && zoomLevel<=10) {
// call the setMarker function for the marker1
} else if (zoomLevel>10 && zoomLevel<=15) {
// call the setMarker function for the marker2
}
也许你想处理缩放更改事件,如果是这样的话: http://code.google.com/apis/maps/documentation/javascript/events.html
Maybe u want to handler the zoom change event, if so look at this: http://code.google.com/apis/maps/documentation/javascript/events.html
这篇关于根据您所在的缩放级别显示Google地图标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!