1

I am trying to visualize a large amount of weather data with GE(the data may change time to time). Ideally, the user could input the data file with locations and weather data. I was wondering how could I create the KML dynamically?

Matthew
  • 9,851
  • 4
  • 46
  • 77
omgMaya
  • 181
  • 2
  • 2
  • 12
  • see http://stackoverflow.com/questions/4296840/php-dynamically-creating-kml-for-multiple-placemarks-on-map – Rachel Gallen Jan 22 '13 at 18:17
  • 1
    More detail would be good here: what creates the data? Where is the data created? Are you trying to get it from something and into Google Earth? Out of Google Earth? If it is a question of input, what format is the data in? etc. – Matthew Jan 22 '13 at 20:08
  • HAHA. It is you again. Thanks. Actually the interface will link to some back-end application. I am only responsible for the front-end and no need to do data transfer. For now I could just assume the data as a txt. This file will include longitude, latitude, altitude and some other values. I learned that I could create dynamic kml with PHP. Do I need to use php? or I could just use javascript. I am trying to input something to the GE and render it. – omgMaya Jan 22 '13 at 21:18

1 Answers1

0

Based on your comment above you will have KML data available from one of two sources: See my answer to this question: Import KML in Maps API V2 (I would ignore the solution by the author here):

If you have the KML accessable at a publically available URL, follow this part of the API: https://developers.google.com/kml/documentation/mapsSupport.

If you want to load locally stored KML files (i.e. you are getting a .txt file on your server) you will need to parse them yourself. There are libraries for doing this in every language. For Javascript as an example: http://code.google.com/p/geoxml3/

If you do end up doing this with the API (your kml/kmz is available as a URL) your JavaScript code is as simple as:

The API Call to load KML from a URL in the JavaScript API where the map var is your google.maps.Map object.

var geoLayer = new google.maps.KmlLayer('URL');
geoLayer.setMap(map);

UPDATE

Note that this thread is relevant to your question as well, and you do have additional options to loading your KML if using the GE Plugin. Unable to load a local KMZ file into a browser with the google earth plugin using fetchkml function

Community
  • 1
  • 1
Matthew
  • 9,851
  • 4
  • 46
  • 77