There are no markers in my map. In response to a click on the map, a pop-up window appears with the Lat / long indicator, shown in decimal up to 5 dp and in degrees in minutes seconds. An open window is always closed before responding to a new click. The position is set by the position: latLng, but the info definition is always in the upper left corner. I spent a few days on it, and I feel that something is missing. The following is a snippet of code. Any ideas?
google.maps.event.addListener(map, 'click', function (event) {
var lat = event.latLng.lat(),
lng = event.latLng.lng(),
latLng = event.latLng,
strHtml;
if (openedInfoWindow != null) openedInfoWindow.close();
alert(latLng);
var infoWindow = new google.maps.InfoWindow({
position: latLng,
content: strHtml,
maxWidth: 420
});
infoWindow.open(map,this);
openedInfoWindow = infoWindow;
google.maps.event.addListener(infoWindow, 'closeclick', function() {
openedInfoWindow = null;
});
});
source
share