OpenLayers vs.
Leaflet
DrupalCamp Vienna, Nov. 2013
The who is who?
Antje Lorch
@ifrik
Site builder
Documentation
OpenLayers
Josef Dabernig
@dasjo
Allrounder
Community
Leaflet
Who are you?
● … and why we do this Session
What does the OpenLayers module?
1. Building queries
> using Views
2. Configuring maps
> Openlayers settings
3. Putting the map(s) on the site
> either using Views or OL blocks
What does the Leaflet module?
1. Building queries
> using Views
2. Configuring maps
> Using the API → hook
3. Putting the map(s) on the site
> Views (step 1) or Leaflet GeoJSON (ajax)
What not in OL & Leaflet modules?
•data input,
•geocoding
•data storage
•proximity search
... but other modules do that.
OL other modules and resources
•Geofield 2
•Geocoder
•OL Blocks
•OL Filters
•OL Feature Popups
•....
Leaflet other modules and resources
•Geofield 2
•Geocoder
•Leaflet markercluster
•Leaflet widget
•Leaflet more maps
•Leaflet label
•....
Drupal
Storage – Query – Display
0. Input data: Geofield Openlayers Widget
0. Input data: Geofield Leaflet widget
:( Beta from Nov 2012, doesn't support Geofield 2.x yet!
1. Query: OpenLayers Data Overlay
1&3. Query & Display: Leaflet map
2 OL maps: General Resources
(Base) Layers: maps & tiles
Styles: Markers
2.1 OL Choose or add your map
2.2 OL Configure your map
2.3 OL Map Specific settings
Base Layer
Layers = Data Overlays
Markers per Layer
Initial Zoom level
and focus
Behavior:
Layerswitcher,
Navigation,
Tooltps etc.
3. OL Put the map in the site
3 Leaflet Put the map in the site
● Not necessary
2.2 Leaflet Configure your map
● Missing some UI?
/**
  * Implements hook_leaflet_map_info().
  */
function leaflet_dcvie_leaflet_map_info() {
return array(
'mapbox dasjo dcvie' =>
array(
'label' => 'mapbox dasjo dcvie',
'description' => t(''),
'settings' => array(
'minZoom' => 0,
'maxZoom' => 8,
'dragging' => TRUE,
'touchZoom' => TRUE,
...
),
'layers' => array(
'control_room' => array(
'urlTemplate' => 'http://{s}.tiles.mapbox.com/v3/ID/{z}/{x}/
{y}.png',
'options' => array(
'attribution' => 'Copyright notes'
)
),
),
),
Leaflet maps
3 Alternative: Leaflet GeoJSON
Allows to use an AJAX-Bounding Box Strategy
Requires Views GeoJSON + Patches :(
Recent geofield changes require changes
https://drupal.org/node/1794848
BBox argument handler fixes
https://drupal.org/node/1839554
Demo time!
Examples
www.moonunderwater.eu
unesco.nl
unesco.nl
geluidvannederland.nl
geluidvannederland.nl
Base tiles
JavaScript Mapping Libraries
● Leaflet
● OpenLayers
● d3 / Protovis
● polymaps
● Modest Maps
My recipe
● Geofield
● Leaflet
● Views GeoJSON
● Leaflet GeoJSON
● Leaflet.markercluster (client-side)
or Geocluster (server-side)
.. and more
● Custom base tiles: Tilemill
● Custom visualization: d3, JavaScript
● Import: Feeds
● Proximity search: Geofield, Search API
Location
?
OpenLayers vs. Leaflet
OpenLayers vs. Leaflet

OpenLayers vs. Leaflet

Editor's Notes

  • #3 Antje
  • #4 Antje
  • #25 - Not too many features like OpenLayers,, … - Small & Quality - modern - Extend - Mobile - fast - 28 kb of javascript code (openlayers 200 - 1mb)
  • #27 r
  • #35 - Free & opensource libraries - commercial: google, bing, yahoo, mapquest, ...
  • #36 - Data: Points, Polygons, Lines, … - HTML5 Location, WKT, Widgets, … - GeoJSON, KML Geofield: Data, Bounding Box, Geoid Address Field / Geocoder File / Open Layers KML Layer Location Geolocation Field
  • #37 Srorage OK, now Query + Display Views, ... Gmap, OpenLayers, Simple Gmap Leaflet Mapbox.js
  • #38 Geofield, HTML5 location Leaflet display settings, Leaflet views, Client-clustering Views GeoJSON, Leaflet GeoJSON Bean Geocluster
  • #41 Why map? Ideas? Visualize spatial phenomena to understand, orientate Disaster recovery Tell a story, treasure maps Social networking, where are my friends? GPS, smartphones, pictures Design and planning
  • #44 - shape, area, direction, distance, scale -
  • #45 - Latitude, longitude – equator - spatial data: points, shapes,