I was looking for a solution to add Google Maps to a Swing-based project. I came across a paid solution (JxBrowser). I didn't want to pay for it to accomplish the tasks that I needed. So, I created my own solution for free. This is a Netbeans project. The project uses JavaFX libraries to display Google Maps on a JFrame. You can access javascript functions from Java and map them to Java functions. All map related functions are inside GoogleMapsViewer class. It extends JFXPanel.
- Import the project from Netbeans.
- Put your API Key in maps.html where it says "YOUR_API_KEY".
- Run the GUI app.
- Enter Center X, Center Y which are the beginning/center coordinates for generating random markers. Radius defines the boundries of generated markers.
- Generate random unique coordinates.
- Add random markers to Google Maps.
- Add info window, label to marker.
- Delete marker.
- Delete all markers.
- Delete specific marker.
- Center map and adjust zoom level.
- Cluster markers.