-1

Is it possible to show the change for Latitude / Longitude in Google Map as the user moves the mouse cursor over a KML polygon ?

The following script works fine for Google Map. Yet it does not change when the user moves the mouse cursor over a polygon region.

google.maps.event.addListener(
 map, 'mousemove',
 updateLatLngBox
);

Snapshot showing the Lat/Long does not change when the user moves into the Blue Region

  • Does the user have to interact with the KML layer? If not, you can use a combination of a known `google.maps.LatLngBounds` created from the KML Layer path, a `google.maps.KmlLayer` (specified here: https://stackoverflow.com/questions/3487142/google-maps-v3-api-kml-layer-messing-with-click-mouse-events) and a regular `mousemove` event listener like you have detailed above. The advantage of using a `google.maps.KmlLayer` is that it displays your KML, but in a way that doesn't affect the events propagated from the map itself. – Adam Jenkins May 23 '17 at 10:01

1 Answers1

0

Partially solved via the following using mouse 'click' :-

google.maps.event.addListener(AreaA, 'click', function(kmlEvent) {
  var latitude = kmlEvent.latLng.lat().toFixed(12);
  var longitude = kmlEvent.latLng.lng().toFixed(12);

  document.getElementById("latLngContainer").innerHTML = 
    "Lat/Long (dd):<br/>" + latitude + "," + longitude;

});