I totally see the benefits of JSON, pull over a lightweight array of data to stuff into my Google Maps (and template through to show a list of the points as well). I've heard a lot of talk about KML.
Which is the preferable way to pull points into Google Maps, JSON || KML? My primary concern is performance, but also breadth of features that could potentially improve the map.
Personally I use json because the kml resulting features are less flexible than the features that you create from parsing json. For example, you can't add a hover event to a polygon from kml.
KML, being XML, is very heavyweight compared to JSON if you're just loading simpler data and will suffer performance penalties not only in network transfer but in parsing time as a result. That's the downside to JSON, of course, is that you're limited not only in expressive power potentially (depending on what the Google Maps components can consume via JSON versus KML), but also on which clients can consume your data. If you give your data in KML, anything that reads KML can use your data, like Google Earth. It's like the RSS of geographic data, that is if you want or need it to be.
These past few months I've done a lot of work with OpenLayers and have really enjoyed it. The library is open source and includes tons of formats out of the box including GeoJSON and KML. Here's an example demoing Google Maps integration. Here's the rest of the examples. Combined OpenLayers and ExtJS and it results in GeoExt (examples here).
I would like to make a case for KML, specially in the context of Google Maps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With