A new API has been created for mouse events in the GMapsFX API which will begin to make it easier to obtain information about mouse events occurring within the Google Map without having to interact with the underlying Javascript API.
So now getting the Lat/Long of a mouse click is a relatively straightforward process.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GoogleMap map = googleMapView.createMap(mapOptions, false); | |
map.addMouseEventHandler(UIEventType.click, (GMapMouseEvent event) -> { | |
LatLong latLong = event.getLatLong(); | |
System.out.println("Latitude: " + latLong.getLatitude()); | |
System.out.println("Longitude: " + latLong.getLongitude()); | |
}); |
We tell the map we want to add a click UI event listener and pass in an event handler which handles a GMapMouseEvent event object. From that object the latitude and longitude of the event can be determined.
Currently the Lat/Long are the only properties available on the GMapMouseEvent object, but additional properties will be added as demand warrants.
Below is a screenshot of one of the example applications included with the GMapsFX project that illustrates how to capture the lat/long of a mouse click.