Markers incorrectly changing location on zoom
I have a set of markers being added to a map at zoom level 15. The markers lat and lng are currently set to the 6th decimal place.
When I zoom in or out the marker locations are moving out of their correct position. Do i need to remove and redraw the markers at each zoom level? do I need to increase the accuracy of my coords? this is driving me crazy...
Test page: http://m.uwosh.edu/api/v1.0/map/ click on the yellow icon in the bottom bar.
I'm creating my markers like so:
function createMarker(data, type)
{
var posn = new google.m开发者_开发百科aps.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);
}
}
You shouldn't have to add/remove the markers as the markers are placed with the lat/long location.
Perhaps some code may help us figure this out.
精彩评论