Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 518
Chaddeus Avatar asked Nov 24 '10 01:11

Chaddeus


4 Answers

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.

like image 88
Argiropoulos Stavros Avatar answered Nov 15 '22 10:11

Argiropoulos Stavros


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.

like image 38
Wyatt Anderson Avatar answered Nov 15 '22 10:11

Wyatt Anderson


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

like image 8
Corey Farwell Avatar answered Nov 15 '22 08:11

Corey Farwell


I would like to make a case for KML, specially in the context of Google Maps:

  1. KML is an official standard curated by OGC;
  2. Google itself has created KML in the first place, and maintains an extensive documentation about it. It even has a library for KML;
  3. Google maps API has good support for KML Layers (although it also has good support for GeoJSON);
  4. A lot of other Google mapping applications (Google Earth, Google My Maps, Google Maps Routing) export KML natively, or offer to download/save the data as KML. That Import/Export functionality, as far as I know, is not so developed for GeoJSON, at least yet (as of 2016).
like image 4
heltonbiker Avatar answered Nov 15 '22 09:11

heltonbiker