2
Answers

How to Mark the Current Location in Google map

mari muthu

mari muthu

8y
242
1
var gmarkers = [];
var map;
for (i = 0; i < gmarkers.length; i++) {
gmarkers[i].setMap(null);
}
function initialize() {
if ("geolocation" in navigator) { //check geolocation available
//try to get user current location using getCurrentPosition() method
navigator.geolocation.getCurrentPosition(function (position) {
$("#result").html("Found your location <br />Lat : " + position.coords.latitude + " </br>Lang :" + position.coords.longitude);
});
} else {
console.log("Browser doesn't support geolocation!");
}
var mapProp = {
center: new google.maps.LatLng(20.593684, 78.96288), //India Lat and Lon
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var marker = new google.maps.Marker({
position: mapProp.center,
icon: "~/pinkball.png",
map: map
});
gmarkers.push(marker);
map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
 
 
hi friends this my code i already get my current location but in that location i want to mark by using one image .i didn't get that result mark is not showned inside the map please help me for this any one known this please share me help me 
Answers (2)