I am trying create a map using google maps v3 api. I have found the below code over internet and I want to show the latitude and logitude in map window instead of address.
When you want the lat and long of any part of the map,try adding the click listeners for the map not the marker. The code should be something like below:
var infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.getDetails({
placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4'
},function(place,status){
if(status === google.maps.places.PlacesServiceStatus.OK)
{
var marker = new google.maps.Marker({
map:map,
position: place.geometry.location
});
google.maps.event.addListener(map, 'click', function(e) {
infowindow.setContent(''+'Longitute'+'' + e.latLng.lng() + '
' +
'Latitude:'+'' + e.latLng.lat()+'' + '');
infowindow.open(map, this);
});
}
});
This will display the lat and long of any location on the map using a info window.