Top Banner
Mapping in Drupal using OpenLayers Peter Vanhee 1st October 2011 - DrupalCamp Spain drupal 7
44

Mapping in Drupal 7 using OpenLayers

May 08, 2015

Download

Technology

Peter Vanhee

Presentation from DrupalCamp Spain 2011 about OpenLayers in Drupal 7.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Mapping in Drupal 7 using OpenLayers

Mapping in Drupalusing OpenLayers

Peter Vanhee1st October 2011 - DrupalCamp Spain

drupal7

Page 2: Mapping in Drupal 7 using OpenLayers

Who am I?

‣ Consumer and contributor to Drupal for over 5 years

‣ Co-founder Youth Agora @youthagora and Nuvole @nuvoleweb

‣ Web consultant in Barcelona @pvhee

Page 3: Mapping in Drupal 7 using OpenLayers

What is OpenLayers?

Page 4: Mapping in Drupal 7 using OpenLayers

OpenLayers is ...

‣ a framework for building map applications

‣ javascript

‣ open source (BSD licensed)

‣ your escape from Google Maps

Page 8: Mapping in Drupal 7 using OpenLayers

Under Developmentdrupal7

Page 9: Mapping in Drupal 7 using OpenLayers

drupal6 drupal7‣ Geofield

‣ Geocoder

‣ ?

‣ ?

‣ ?

‣ ?

‣ OpenLayers CCK

‣ OpenLayers Geocoder

‣ OpenLayers Filter

‣ Geo Taxonomy

‣ OpenLayers Plus

‣ OpenLayers Proximity

Note that this list is incomplete

Page 10: Mapping in Drupal 7 using OpenLayers

Modules

‣ ctools

‣ openlayers openlayers_ui, openlayers_views

‣ geofieldgeoPHP

‣ views

Page 11: Mapping in Drupal 7 using OpenLayers

Example

Page 12: Mapping in Drupal 7 using OpenLayers

Geo Data‣ Data with

latitude/longitude (e.g. integers)

‣ CCK Field: geofieldsupports points, lines & polygons

‣ Can be anything that is available in Views!

field storage input field type

Page 13: Mapping in Drupal 7 using OpenLayers

Adding geo data

with OpenLayers Map Widgetwith lat/lng fields

Data is stored in geofield

Page 14: Mapping in Drupal 7 using OpenLayers

And our rendered node

Page 15: Mapping in Drupal 7 using OpenLayers

Mapping in 3 steps

1. LayerServices: Google Maps, MapBox, ... Files: KML, XML, ...Drupal nodes via Views

2. MapConfiguration for a single map

3. ViewDisplays the map using Views

Page 16: Mapping in Drupal 7 using OpenLayers

1. Layer2. Map3. View use Views to select data from CCK

Page 17: Mapping in Drupal 7 using OpenLayers

configure data source to pick up the location

1. Layer2. Map3. View

Page 18: Mapping in Drupal 7 using OpenLayers

pass additional data to the layer

1. Layer2. Map3. View

Page 19: Mapping in Drupal 7 using OpenLayers

use OpenLayers module to configure map

1. Layer2. Map3. View

Page 20: Mapping in Drupal 7 using OpenLayers
Page 21: Mapping in Drupal 7 using OpenLayers

set layers (tiles and data) and styles

Page 22: Mapping in Drupal 7 using OpenLayers
Page 23: Mapping in Drupal 7 using OpenLayers

use Views to display map

1. Layer2. Map3. View

Page 24: Mapping in Drupal 7 using OpenLayers

select map to display

1. Layer2. Map3. View

Page 25: Mapping in Drupal 7 using OpenLayers
Page 26: Mapping in Drupal 7 using OpenLayers

Step by step

Add geofield (Field)

1. Create data overlay (Views)

2. Create map (OpenLayers)

3. Render map style (Views)

Page 27: Mapping in Drupal 7 using OpenLayers

Improvements

Page 28: Mapping in Drupal 7 using OpenLayers

Map Behaviors

‣ Pop Up

‣ Zoom to layer

‣ Cluster

‣ Write your own(javascript)

Page 29: Mapping in Drupal 7 using OpenLayers
Page 30: Mapping in Drupal 7 using OpenLayers

Change Layers

‣ Google Maps

‣ MapBox

‣ Create your own (e.g. via TileMill)

Page 31: Mapping in Drupal 7 using OpenLayers

set layers (tiles and data) and styles

Page 32: Mapping in Drupal 7 using OpenLayers

Geoserver1. Drupal outputs WFS

via Views

2. Geoserver reads WFS and creates map

3. Openlayers reads Geoserver map, displays and facilitates interaction

http://drupal.org/project/wfsdrupal6 http://geoserver.org!

Page 33: Mapping in Drupal 7 using OpenLayers

Tilemill

Create your own tiles, and render in Drupal

Page 34: Mapping in Drupal 7 using OpenLayers

Extending via Contributed Modules

Page 35: Mapping in Drupal 7 using OpenLayers

https://github.com/developmentseed/openlayers_plus

openlayers_plus

scale points, add tooltips, ...

drupal6source: www.europeancampus.eu

Page 36: Mapping in Drupal 7 using OpenLayers

‣ From address to location

‣ Use geocoder services (e.g. Google Geocoder)

‣ Can take values from Address Field or any other text

geocoder drupal7

!

Page 37: Mapping in Drupal 7 using OpenLayers

geocoder drupal7

Page 38: Mapping in Drupal 7 using OpenLayers

geocoder drupal7

Page 39: Mapping in Drupal 7 using OpenLayers

Would be nice to...

!

‣ Render live output of geocoding

‣ For Drupal 6, check out the excellent Openlayers Geocoder by @nuvoleweb

Page 40: Mapping in Drupal 7 using OpenLayers

Extending via Code

Page 41: Mapping in Drupal 7 using OpenLayers

hook_openlayers_behaviors()hook_openlayers_styles()

‣ hook_openlayers_map_preprocess_alter()hook_openlayers_map_alter()

‣ hook_openlayers_layer_types()hook_openlayers_layers()

‣ hook_openlayers_behaviors()

‣ hook_openlayers_styles()

‣ hook_openlayers_maps()

see openlayers.api.php

Page 43: Mapping in Drupal 7 using OpenLayers

Thanks!

Peter Vanhee@pvhee

Page 44: Mapping in Drupal 7 using OpenLayers

Questions?

Peter Vanhee@pvhee

Importing and syncing content using FeedsSunday, 12pm, Sala Cenatic pvhee

Drupal + GIS: Convertiendo Drupal en un GeoCMSSunday, 4pm, Sala Microsoft plopesc