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)
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.
- Prerequisites: Install Drupal 7 and the following contribution modules:
- Main modules for this tutorial
- GeoField (1.1, not 2.x for Leaflet)
- Leaflet (also the Leaflet Library as indicated by the Leaflet module)
- ...and many supporting modules
- Entity API
- Main modules for this tutorial
Geolocation provides a Drupal 7 field for storing Longitude/Latitude pairs.
It is a light-weight alternative for the Geofield module, since it does not automatically enables own widgets, but implements the widgets in submodules.
Other helper modules:
The Geomap module will render a Google map in a block.
The locations placed on the google map are obtained by
analysing the current page for GEO microformat informaton.
When this info exists, a map will be rendered, when there
is no location information, no map will appear.
More information on GEO Microformats:
The Geolocation module is required to use the Geomap Fields sub-module. Otherwise there is are requirements.
Note: It is assumed that you have Drupal up and running. Be sure to
check the Drupal web site if you need assistance. If you run into
problems, you should always read the INSTALL.txt that comes with the
Drupal package and read the online documentation.
- Download the geomap module. Optionally, download the geolocation module to use the geomap fields sub-module.
- Place the modules in a contributed modules directory, such as sites/all/modules.
- Enable the module by navigating to: Administer > Modules
Go to Administer > Site Building > Blocks
Assign the "Geo Microformat Googlemap" to a region
I started this as part of a project and there is an introduction you might like to read in context under Openlayers Proximity Search – D7 - the background - discussing it beyond coding ....
The attempt to build a website allowing proximity search of organisations that offer help, support, advice and/or are doing projects. The project started in July 2012 - Drupal core 7.15.
Eventually you will figure out that there are several ways of doing this:
- Gmap + Location
I decided to stay in the middle and more by accident I worked with Openlayers. Though, it seems to turn out that this is the way ahead.
I guess I followed Openlayer because I wanted to do this without google. It has not happened yet – Google is still in there, but then not all will happen instantly.
Btw. the short-cut around this detailed tutorial is here - Need a simple Google Maps solution; lost in the labyrinth of modules - and by using this module - http://drupal.org/project/ol_locator.
All comments and improvements welcome - as all things in life - it's work in progress ...
1. Modules:Read more
Leaflet currently offers:
- Field formatter that can show a map for fields that contain geospatial data
- Views integration that plots data on a map (using the sub module Leaflet Views)
- API for displaying data on a map
Leaflet extension modules
- Leaflet Markercluster - Provides Beautiful Animated Marker Clustering functionality for Leaflet using the Leaflet MarkerCluster library.
- Leaflet Widget for Geofield - a Geofield widget that uses the Leaflet widget plugin for adding and removing geometries.
- Leaflet More Maps - adds over 20 attractive map styles such as MapBox, Stamen, Thunderforest and Esri.
- Leaflet MapBox - use your own MapBox map tiles in your map views.
- Leaflet Google Maps - adds the possibility to choose Google Maps layers in leaflet maps.
In this example use case, Druplicon the blogger travels around the world and blogs about the awesome stuff he encounters on his travels.
What's Views GeoJSON for?
Druplicon's blog-site will collect location information for each post. Views GeoJSON allows using Views to provide a GeoJSON feed of this locative data that can be added to a map, or that another site can collect (maybe with the Feeds module) and utilize.
Setting up Views GeoJSON
- Add a geofield to a content type, in this example basic page
- Geofield depends on geoPHP