Configure a GeoField instance where the data is retrieved from a KML File.

The example: import the city of Vienna waste collection centers into a GeoField and display them on a Leaflet map.
Data Source: Stadt Wien - data.wien.gv.at
Source URL: http://data.wien.gv.at/katalog/altstoffsammelstellen.html
Licence: Creative Commons Attribution 3.0 Austria (CC BY 3.0)
Link to Terms of Use: http://data.wien.gv.at/nutzungsbedingungen/index.html

One note about this tutorial:
It does not work like the Drupal OpenDataVienna project (http://drupal.org/project/odv) in that this tutorial will import the KML file once and create the data from that file. The OpenDataVienna project attempts to grab the updated GeoJSON file on cron run from the source and create one Node per element from the GeoJSON file.

  1. Prerequisites: Install Drupal 7 and the following contribution modules:
    1. Main modules for this tutorial
      1. Geocoder
      2. GeoPHP
      3. GeoField (1.1, not 2.x for Leaflet)
      4. Leaflet (also the Leaflet Library as indicated by the Leaflet module)
      5. File
    2. ...and many supporting modules
      1. CTools
      2. Entity API
      3. Libraries
      4. Views
      5. jquery_update (Use 1.7 so there are no small bugs :)
      6. Field Group (Hels with the structure, not required)
  2. Create a new node type (or use an existing node type). The remainder of this tutorial will use the default Article node type
  3. Manage the fields:
    1. Create a new group called KML
    2. Create a file field called KML File (see images 1 and 2)
      1. Enable Display Field: yes
      2. Files displayed by default: yes
      3. Label: KML File
      4. Allowed file extensions: kml
      5. File directory: kml
    3. Create a GeoField field called KML GeoField with widget Geocode from another field (see images 3 and 4)
      1. Label: KML GeoField
      2. Geocode from field: KML File
      3. Geocoder: KML
      4. Multi-value input handling: Match Multiples (default)
      5. Number of values: Unlimited
  4. Manage the display of the article (see image 5)
    1. Leaving the display as-is will cause the GeoField to be displayed as a Well-Known-Text.
    2. To display it as a Leaflet Map. Change the display format and then change the settings of Leaflet Map to OSM Mapnik - Note that at the time of this tutorial, Leaflet module had problems with MULTIPOINT values. It may not display properly.
  5. Download the geojson file to make your content:
    1. Download the file from http://data.wien.gv.at/katalog/altstoffsammelstellen.html by right clicking on the KML link and saving as waste_collection_centers_vienna.kml
  6. Now that the node type is set up. Create your node!
    1. http://yoursite.com/node/add/article
    2. Title: An article outlining the waste collection points of the City of Vienna, Austria
    3. KML File: select the waste_collection_centers_vienna.kml file from above
    4. When ready, save the article
  7. You are done.
AttachmentSize
1.png33.46 KB
2.png51 KB
3.png33.76 KB
4.png35.74 KB
5.png9.98 KB

Comments

grn’s picture

Hi!

Thanks for this very good guide!

I did not manage to get Leaflet working, so I used the Geofield Map instead.

I had a 3 MB KML-file - i think it was too big to be handled by Geofield. I tried with a gpx-version of the file and it worked! Perfect.

The result is here: http://heleplanter.dk/forberedelse-til-ekspedition-heleplanter-2013 (Danish)

BR.
GrN.dk

jjchinquist’s picture

I see that your site has 1 route that was imported. Have you done any projects since then that involve more?

pal4life’s picture

Hi,
The download GeoJSON link http://data.wien.gv.at/katalog/altstoffsammelstellen.html is broken, please provide an alternative.

Thanks.

danielmb85’s picture

Hi thanks for tutorial, excelent
but I need see the information or labels into KML, for example if KML have bubles tounc him, ant his mostrate labels of buble

mobydeic’s picture

I followed this tutorial and it perfectly enabled a node to display a map with pins. However, my KML dataset also contains descriptions with name, address, etc., that I would like to populate the popup fields. Is this doable?

dalearyous’s picture

did you figure this out? i would also really like to be able to do this. i know the pop up field accepts tokens but the point data in the KML isn't getting mapped anything token related.

mobydeic’s picture

No, I haven't found any workable solution for this yet. I was hoping someone might comment on this here.