我正在尝试让标记管理器在 Google Maps V3 上工作。我试图复制这里教程页面上显示的内容,但我似乎无法让它工作。这是我目前使用的代码:
function gmapInit()
{
drawMap();
}
function drawMap()
{
var center = new google.maps.LatLng(..., ...);
var mapOptions = {
center: center,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
zoomControl: true,
streetViewControl: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var mgr = new MarkerManager(map);.
google.maps.event.addListener(mgr, 'loaded', function()
{
createMarkers(map, mgr);
});
map.setCenter(center);
}
function createMarkers(map, mgr)
{
var bounds = new google.maps.LatLngBounds();
<c:forEach var="place" items="${places}">
var point = new google.maps.LatLng(..., ...);
bounds.extend(point);
var image = new google.maps.MarkerImage("...",
new google.maps.Size(25, 25),
new google.maps.Point(0, 0),
new google.maps.Point(0, 25),
new google.maps.Size(25, 25));
var marker = new google.maps.Marker({
position: point,
map: map,
icon: image
});
google.maps.event.addListener(marker, 'click', function()
{
...
});
mgr.addMarker(marker, 20);
</c:forEach>
map.fitBounds(bounds);
mgr.refresh();
var listener = google.maps.event.addListener(map, "idle", function()
{
if (map.getZoom() > 16)
{
map.setZoom(16);
}
});
}
但是,无论我输入什么值以及放大什么缩放级别,图标仍然会继续显示。此外,我不断收到以下错误:
grid is undefined
对此的任何见解表示赞赏:)
我正在使用的 MarkerManager 文件可以在这里找到