Markers move incorrectly when scaling

I have a set of markers added to the map at zoom level 15. The lat and lng markers are currently set to the 6th decimal position.

When I increase or decrease the location of the marker, they get out of their correct position. Do I need to delete and redraw markers at each zoom level? Do I need to improve the accuracy of my coordinates? it drives me crazy...

Testing page: http://m.uwosh.edu/api/v1.0/map/ click the yellow icon in the bottom panel.

I create my markers like this:

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);
    }
}
+3
source share
1 answer

/ , / .

, - .

+1

Source: https://habr.com/ru/post/1796388/


All Articles