I am getting problem in user location fesching
Problem is that when I move device with current location the older one marker is not remove, insted it creates new marker every time, I ha ve user clearwatch () but its stop displying map also
Here is my code snap
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type=“text/javascript”
src="[http://maps.googleapis.com/maps/api/js?key=]]…APIkey…[&sensor=true">
</script>
<script type=“text/javascript”>
var accuracy;
var watchID;
var geoLoc;
function initialize()
{
var locationMarker = null;
var myOptions = {
center: new google.maps.LatLng(]]…USER_LOCATION.LATITUDE…’, '…USER_LOCATION.LONGITUDE…[[),
zoom: 1,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById(“map_canvas”),
myOptions);
watchID= navigator.geolocation.watchPosition(getLocation,unknownLocation,myOptions);
function getLocation (pos)
{
var im = ‘http://www.robotwoods.com/dev/misc/bluecircle.png’
var latitde = pos.coords.latitude;
var longitude = pos.coords.longitude;
var myLatLng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
var userMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: im
});
alert('Your current coordinates (myLatLng) are : ’ + latitde + ', ’ + longitude);
};
window.setInterval( function () {
getLocation();
},
5000
navigator.geolocation.clearWatch(watchID);
);
function unknownLocation()
{
alert(‘Could not find location’);
}
var image = new google.maps.MarkerImage(‘localhost/streetculture/images/1/img1.png’,
new google.maps.Size(25, 28),
new google.maps.Point(0,0),
new google.maps.Point(12, 28)
);
]]…markerString…[[
}
</script>
</head>
<body onload=“initialize()”>
Please guide me