google-maps - 标记错误地更改了缩放位置

标签 google-maps google-maps-api-3 google-maps-markers

我在缩放级别15上将一组标记添加到 map 。标记lat和lng当前设置为小数点后第六位。

当我放大或缩小标记位置时,它们会移出其正确位置。我是否需要在每个缩放级别上删除并重新绘制标记?我需要提高坐标的准确性吗?这真让我抓狂...

测试页: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 - 标记错误地更改了缩放位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5199018/

相关文章:

javascript - 缩小谷歌地图的事件?

javascript - 从自动完成地址输入中获取纬度和经度,并使用谷歌地图 API 显示下面的 map

android - 如何在二维 View 中显示谷歌地图?

javascript - 设置多边形在谷歌地图中的显示顺序

android - 如何处理Android应用程序中标记的双击

javascript - Google Markers setVisible true/false 显示/隐藏

java - Google map API Java 默认缩放

Android Google Maps V2 Cluster 隐藏信息窗口

javascript - 谷歌地图 v3 : need multiple draggable markers to update HTML input fields

javascript - onclick 移动谷歌地图中心点