【发布时间】:2011-07-09 02:43:20
【问题描述】:
我将一组标记添加到缩放级别为 15 的地图中。标记 lat 和 lng 当前设置为小数点后 6 位。
当我放大或缩小标记位置时,它们会移出正确的位置。我需要在每个缩放级别删除并重绘标记吗?我需要提高坐标的准确性吗?这快把我逼疯了……
测试页面:http://m.uwosh.edu/api/v1.0/map/ 点击底部栏中的黄色图标。
我正在像这样创建我的标记:
function createMarker(data, type)
{
var posn = new google.maps.LatLng(data.lat,data.lng);
var title = data.title;
var image,shadow,shape;
if (data.typeId === '101') {
image = new google.maps.MarkerImage('/api/v1.0/map/images/buildings.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(24, 28),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 28));
shadow = new google.maps.MarkerImage('/api/v1.0/map/images/shadow-buildings.png',
// The shadow image is larger in the horizontal dimension
// while the position and offset are the same as for the main image.
new google.maps.Size(39, 28),
new google.maps.Point(0,0),
new google.maps.Point(0, 28));
}
var markerOptions = {
position: posn,
title: title,
shadow: shadow,
icon: image
};
var marker = new google.maps.Marker(markerOptions);
// could add event handler here
//add marker to array for latter use
if (type === 'building') {
buildingMarkers.push(marker);
}
}
【问题讨论】:
标签: google-maps google-maps-api-3 google-maps-markers