Which data source is preferable for Google Maps, KML or JSON? Which data source is preferable for Google Maps, KML or JSON? json json

Which data source is preferable for Google Maps, KML or JSON?


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).