Google Maps Api V3 - Marker Disappears After Setposition
I'm having a problem with the maps markers. The map and marker load fine on the inital pageload. But when I try to update the marker location it simply disappears. The Alert window
Solution 1:
function(data) {
alert(data);
position = new google.maps.LatLng(data);
..
Looks very wrong; data
is a string, probably containing "lat, lng"
, which google.maps.LatLng
cannot be initialized with. new google.maps.LatLng
requires a pair of type number
in the arguments, like (number, number)
.
Do this instead :
data = data.split(',');position = new google.maps.LatLng(parseFloat(data[0]), parseFloat(data[1]));
Post a Comment for "Google Maps Api V3 - Marker Disappears After Setposition"