WHERE IT'S AT - DrupalCamp Ohio

56
WHERE IT’S AT Location and Mapping in Drupal: Martin Anderson-Clutz Digital Echidna

Transcript of WHERE IT'S AT - DrupalCamp Ohio

WHERE IT’S AT Location and Mapping in Drupal:

Martin Anderson-Clutz

Digital Echidna

What This Presentation IS

•  A primer on mapping and location for websites

•  A comparative look at Drupal solutions

•  An outgrowth of my personal experience in in

building a location and mapping site

–  YMMV

•  A work in progress

–  Feedback is welcome!

What it IS NOT

•  Detailed, step-by-step instructions

•  An exhaustive look at every option

available

–  Chime in if you have a favourite that isn’t

mentioned!

CONTEXT

Use Cases

•  Static Map – “Our Locations”

•  Dynamic Map – “Users Logged In”

•  Relative Locations – “Retailers < 10km”

Core Concepts

•  Mapping

–  Visualizing location data, often with known

landmarks for reference

•  Geocoding

–  Enriching the description of a location with

geographic coordinates

•  Description: “103 King St., London, ON”

•  Coordinates: 42.981860, -81.251414

OPTIONS

Let’s look at some

Mapping Options

•  Google, OpenStreetMaps, Leaflet, Bing,

Yahoo, MapQuest, etc.

•  Considerations:

–  Customizability

–  License restrictions

•  Limits

•  Use in paid and/or private sites

•  Offline use

Geocoding Options

•  Google, OpenStreetMaps, Bing, Yahoo,

MapQuest, etc.

•  Considerations:

–  Limits

–  Speed

–  Uptime

–  Able to store results

API Limits

Drupal Options

•  Raw embed

•  Simple Google Maps

•  Location Map

•  Location

•  Geolocation Field

•  Get Locations

•  GeoField

Raw Embed

•  Put location into Google Maps (or other

map site with embed function)

•  Copy and paste embed code into

Drupal (body text, block, bean, etc.)

•  Ensure text format applied allows

necessary tags

Raw Embed

•  PRO

–  Simple setup

–  No API key required

•  CON

–  Update requires redo on external site

–  Allowing editor update may require allowing

broader access on rest of site

–  Doesn’t scale

Simple Google Maps

•  100% reliant on Google

•  No geocoding, output is effectively a

single-result Google Maps search

•  Update the input text to update the

address

Simple Google Maps

•  PRO

–  Simple to implement

–  Simple to update

–  No API key required

•  CON

–  No option to manually tweak location or map

–  Potential for bad (even erroneous) input

–  Only show one location

Location Map

•  Similar to Simple Google Maps – relies

on Google, map for one node

•  Allows for fine tuning of location

Location Map

•  PRO

–  Simple to implement

–  Simple to update

–  No API key required

–  Option to manually tweak location or map

•  CON

–  Only show one location

Location, GMap

•  Location provides an API, storage, and

geocoding

–  Submodules provide additional data points

and integrations

•  Gmap module provides maps

–  May be possible to use Get Locations Map

instead

Location, GMap

•  PRO

–  Proximity search is baked in

–  Views integration

•  CON

–  Limited options for geocoding and mapping

–  Was late to game with D7, no releases yet for D8

–  Fatal error in Location geocoding config. Raised two

years ago, no resolution

–  Non-standard way of managing attachment to content

types

Geolocation Field

•  Provides a field designed to be a simple

method for storing coordinates and related

data

•  Options for geocoding, proximity, HTML5

input and maps by Google

•  Stable D8 release already available, as a

complete rewrite

Geolocation Field

•  PRO

–  Powerful

–  Simple setup

–  Use with all fieldable entities

–  Sweet HTML5/Google Places input

–  D8 ready-ish

•  CON

–  Current integrations tied to Google

–  Map input doesn’t allow for storage and display of address

Example Interface

Example Config

Get Locations

•  By default builds a map per node and per content type

•  Options to use different libraries to cluster, different markers,

etc.

•  Google Maps API v3, Leaflet, others for mapping, geocoding

via Google or OpenStreetMaps

•  Can be used in conjunction with Views, Geofield, Addressfield,

Geolocation, Location, Getdirections, Smart IP, Openlayers,

Colourbox, more

•  Get Locations Fields does a Google Places search on place

name and will populate address

•  Current D8 stance is leaving the work of porting to others

Get Locations

•  PRO

–  Views support

–  Very active development

–  Loads of options for input, display

–  Populates address information

•  CON

–  No D8 releases yet

–  Works best with locations already in Google

Budweiser Gardens

Bud Gardens Interface

Budweiser Gardens

GetLocations Config

GetLocations Config

GetLocations Config

GetLocations Config

GeoField

•  Perhaps the most talked about D8 location

solution

•  By itself is a container for coordinate data

–  Addressfield and Geocoder to interpret from natural

language

•  Multiple mapping solutions

–  Openlayers is an amazing but complex toolkit

•  Proximity search including Solr

GeoField

•  PRO

–  Ability to customize virtually any part of the location

handling and mapping

–  Seems to be the solution with the most momentum

•  CON

–  You’re about to find out how deep the rabbit hole goes

–  Some challenges in using different pieces to assemble

a solution

–  No documentation yet for recommended version of

OpenLayers (7.x-3.0-beta3)

Lehigh University

Lehigh University

Lehigh University

Lehigh University

Lehigh University

•  https://memories.lehigh.edu/locations/

159

Example Interface

Example Interface

Addressfield Config

GeoField, OpenLayers

OpenLayers: Map Settings

OpenLayers: Map Settings

OpenLayers: Layers, Sources

OpenLayers: Controls

OpenLayers: Interactions

OpenLayers: Components

Drupal 8

•  Geolocation – stable

•  GetLocations – asked for assistance

•  Geofield – alpha

•  Addressfield – replaced by Address (beta)

•  Geocoder – beta

•  Leaflet – beta

•  OpenLayers – to start after 7.x-3.x branch stable

PIECING THEM TOGETHER

Location Tools Simple Google Map Location Map Geolocation Field Location Get Locations GeoField

D7 7.x-1.2 7.x-2.3 7.x-1.6 7.x-3.7 7.x-1.17 7.x-2.3 Released 2014-Jan-03 2014-May-24 2014-Nov-03 2015-Aug-04 2015-Oct-08 2014-Sep-21 D7 Users 26,954 13,355 12,394 47,755 9,099 39328 D8 8.x-1.x-dev 8.x-2.x-dev 8.x-1.4 n/a n/a 8.x-1.0-alpha1 Released 2015-Oct-11 2013-Sep-30 2014-Oct-12 2014-Oct-28 D8 Users 20 36 14

Dependencies

Modules GMap Module (for map) Libraries Addressfield

Libraries Services Google Google Google

Views integration N Y Y Y Y Proximity N N Y Y Y Y Documentation N N N Y Y Y

Submodules Location, User Locations, Phone and Location Fax, Location Search, Location CCK, Location Generate, Location Add Another, Location Entity, Search API Location Taxonomy, Location Email

Getlocations Search, Getlocations Block, Getlocations Location Taxonomize, Getlocations Map, Getlocations Leaflet, Getlocations Tools, Getlocations GPS

Compatible Modules: Addressfield, OpenLayers, Static Map, Leafle, Leaflet Widget, Geocoder, Geocoder AutoComplete, Address Field, Sync PostGIS, Openlayers Apachesolr, Openlayers CCK Migrate, RSS Field Formatters, Views GeoJSON, Search API Location, Spatial Tools, Geofield PostGIS, Geofield Proximity Plugin

Mapping Tools Simple Google

Map Location MapGeolocation Field GMap Get Locations Leaflet OpenLayersD7 7.x-1.2 7.x-2.3 7.x-1.6 7.x-2.10 7.x-1.17 7.x-1.3 7.x-3.0-beta3 Released 2014-Jan-03 2014-May-24 2014-Nov-03 2015-Sep-08 2015-Oct-08 2015-Oct-09 2015-Jun-25 D7 Users 26,006 13,477 12027 41,299 9,099 9.839 13,383

D8 n/a 8.x-2.x-dev 8.x-1.4 (2015-

Oct-14) n/a n/a 8.x-1.x-dev n/a Released 2013-Sep-30 D8 Users 4

Dependencies

Modules Libraries Geofield, Libraries, cTools and Entity

Libraries Leaflet Services Google Google Google

Views integration Y Y Proximity Y Y Documentation N Y

Submodules GMap Location, GMap Taxonomy, GMap Macro Builde

Getlocations Search, Getlocations Block, Getlocations Location Taxonomize, Getlocations Map, Getlocations Leaflet, Getlocations Tools, Getlocations GPS

OpenLayers UI, OpenLayers Views, OpenLayers Geofield, OpenLayers Examples, OpenLayers Bloc, OpenLayers Contextual Links, OpenLayers Services

ROCK IT

Time to

Resources

•  http://socialcompare.com/en/comparison/sites-internet-de-cartographie

•  http://www.programmableweb.com/news/top-10-mapping-apis-google-maps-microsoft-bing-maps-and-

mapquest/analysis/2015/02/23

•  http://www.programmableweb.com/news/7-free-geocoding-apis-google-bing-yahoo-and-mapquest/

2012/06/21

•  http://stackoverflow.com/questions/2958714/storable-geocoding-reverse-geocoding-services?rq=1

•  http://geocoder-php.org/

•  http://gis.harvard.edu/services/blog/geocoding-best-practices

•  http://www.gisgraphy.com/compare/

•  https://geoservices.tamu.edu/Services/Geocode/OtherGeocoders/

•  https://www.drupal.org/node/1704948

•  https://events.drupal.org/losangeles2015/sessions/location-location-location-mapping-drupal

QUESTIONS?

Martin Anderson-Clutz

@mandclu

[email protected]