Create KML documents using Google Maps
In the previous post, the sample KML document was one I edited by hand. I could have saved some time by using Google Maps to generate the KML for me. Here’s a quick guide on how to use Google Maps to generate a KML document very similar to the one in the previous demo.
- Point your browser to http://maps.google.com, and search for some location. Below, I searched for the city hall in London, Ontario. Click the marker on the left hand side, google maps will open a ‘bubble’ above the location on the map. Click the Save to Map link, then click the Save button.

- Next, click the Search Nearby link, and search for restaurants near the city hall. As in step 1, repeat the steps of clicking some markers in the left, then save the markers to your map. Do the same for nearby hotels.

- Once you have a list of markers saved to your map, click the My Places button on the left of the screen, then click the Maps button below it, and finally click the My Saved Places link (assuming you kept the default map name).

- You should see the list of markers you selected in steps 1 and 2 above. Click on the KML link to save the markers to KML format. A dialog will appear to save to the local filesystem.


Want more?
If you poke around the Google Maps interface, you’ll notice that you can share your maps publicly. The share button will pop up a dialog giving a link to your public map. If you append ‘&output=kml‘ to that URL, the map will be returned as a KML. You could use this URL as an hosted map for the KMLPointsLayer, rather than downloading the KML to file.
In a future post, I’ll explore dynamically generating KML map data on demand using the Google Map APIs to feed the KMLPointsLayer component.
Like this post?
If you like this blog posting, please don’t forget to click the Like buttons. Also, you can send comments to the Codename One Discussion Forums, I check there fairly regularly.