I don't think this is possible from what I read, but is there away to check if my map marker is null in the following code? I read something about prototypes, but I'm not sure if that's what I need to use. Here is the code:
this.currentLocation = function(latitude, longitude) {
if (loc_marker != null) {
loc_marker.setPosition(new google.maps.LatLng(latitude, longitude);
}
else {
var loc_marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
title: "Here"
});
loc_marker.setMap(map);
}
};
I'm trying to move a marker on a Google Map each time the location changes. I want to check to see if a marker has been set, and if it has then I'll just change the position using setPosition();
If you have any suggestions I'd really appreciate it!