26
Geolocation in Drupal (nodes & users) By Andrew M. Riley Mediacurrent Consultant @andrewmriley

Geolocation in Drupal

Embed Size (px)

DESCRIPTION

Maps and geolocation are becoming more and more important to the sites we build as the scope of our smallest projects become regional, national and global. Does your next project need to list store locations that sell a product world wide? Do you need to limit content for certain country descriptions? While these thoughts might be scary at first I promise it isn't voodoo and at the end of the talk you will know how to do all of these things.In this session I will walk you through Drupal common ways to:- Add maps to your site- Create locations on your maps (with and without views)- Locate your users in realtime- Search for locations within a distance- Use mobile devices for geolocation

Citation preview

Page 1: Geolocation in Drupal

Geolocation in Drupal(nodes & users)

By Andrew M. RileyMediacurrent Consultant

@andrewmriley

Page 2: Geolocation in Drupal

Goal

Introduce users to basic mapping concepts, OpenLayers configuration in Drupal and Geocoding users based off of IP address or device location.

Disclaimer: Getting fancy may require some type of programming knowledge.

Page 3: Geolocation in Drupal

Mapping in General

 

Page 4: Geolocation in Drupal

 

GIS

A geographic information system, geographical information science, or geospatial information studies is a system designed to capture, store, manipulate, analyze, manage, and present all types of geographically referenced data. In the simplest terms, GIS is the merging of cartography, statistical analysis, and database technology.Source: http://en.wikipedia.org/wiki/GIS

Page 5: Geolocation in Drupal

 

Geolocation

Geolocation is the identification of the real-world geographic location of an object, such as a cell phone or an Internet-connected computer terminal. Geolocation may refer to the practice of assessing the location, or to the actual assessed location.Source: http://en.wikipedia.org/wiki/Geolocation

Page 6: Geolocation in Drupal

 

Geocoding

Geocoding is the process of finding associated geographic coordinates (often expressed as latitude and longitude) from other geographic data, such as street addresses, or zip codes (postal codes). With geographic coordinates the features can be mapped and entered into Geographic Information SystemsSource: http://en.wikipedia.org/wiki/Geocoding

Page 7: Geolocation in Drupal

Recap

GIS - System for mapping points and interacting with points.

Geolocation - Real world location of an object represented as coordinates. Could be the action of looking up or the stored values.

Geocoding - The action of looking up coordinates to map real world objects.

Page 8: Geolocation in Drupal

Creating a map

 

Page 9: Geolocation in Drupal

The GMap Way

Location Module + GMap

Page 10: Geolocation in Drupal

The OpenLayers Way

OpenLayers+

Geocode+

Geofield

Page 11: Geolocation in Drupal

OpenLayers (map display)

• Manages information about the maps (not points)• Displays Maps• Integrates with views

Page 12: Geolocation in Drupal

Geofield (storage)

• Creates a new field type• Flexible Output• Ties in with Geocode module• Can display a map for users to select a location

Page 13: Geolocation in Drupal

Geocode (lookup)

• Converts addresses into lat/long• Uses the Geofield field type for storage• Pulls information from other fields• Can use different geocoding engines• Good user experience• Geocoding can be wonky outside of the U.S.

Page 14: Geolocation in Drupal

OpenLayers Proximity

• ***There is currently no D7 version***• Lets users search by distance• Uses view as its interface

Page 15: Geolocation in Drupal

Locating your users

 

Page 16: Geolocation in Drupal

Why?

• Hide/Change options depending on which country the user is in

• Redirect the user to a different version of the site• Better user identification• Better user experience

Page 17: Geolocation in Drupal

How?

1. Find out the users IP Address– Lookup the IP Address somehow and find out the location

data.– ???– Profit

Page 18: Geolocation in Drupal

Three Questions

1. Will I be using this on mobile?

– How much money do I want to spend?

– Can I process the data at a later date? (and how much data)

Page 19: Geolocation in Drupal

Google Loader

Pros:• Free• Returns more than just Lat

& Long• Unlimited Queries• 2-4-1 Loading of JQuery

Cons:• Not always reliable• Requires an external

source• Mobile & International

results unreliable

Page 20: Geolocation in Drupal

HTML5 Geolocation

Pros:• Works great on mobile• Uses GPS if possible• Free

Cons:• Browser support is

unreliable*• Asks the user if you can

use their location• Only returns Lat & Long

Page 21: Geolocation in Drupal

Pay Databases & Services

Pros:• Can be internal or external• Doesn't ask the user to

use their location

Cons:• Can cost a lot of money• Could have limited number

of queries• Might have the wrong

location for mobile• International data varies

on levels below country

Page 22: Geolocation in Drupal

Which one to use?

The right tool for the job + a backup method

or

Use the Smart IP module w/ Device Geolocation

($_SESSION['smart_ip']['location'])

Page 23: Geolocation in Drupal

ModulesOpenLayershttp://drupal.org/project/openlayers

Geocodehttps://github.com/fillerwriter/geocode

Geofieldhttp://drupal.org/project/geofield

Smart IPhttp://drupal.org/project/smart_ip

Device Geolocationhttp://drupal.org/project/device_geolocation

Page 24: Geolocation in Drupal

Pay IP Services

MaxMindhttp://www.maxmind.com

IP2Locationhttp://www.ip2location.com

IPInfoDBhttp://ipinfodb.com/register.php

Page 25: Geolocation in Drupal

More Info

OpenLayers (D6) Presentation by Patrick Hayes(Far more technical than my talk)http://yadadrop.com/drupal-video/gis-mapping-drupal-openlayers-geo

OpenLayers (D7) Docshttp://drupal.org/node/595872

OpenLayers (JS Library)http://openlayers.org/

Page 26: Geolocation in Drupal

Geolocation in Drupal(nodes & users)

By Andrew M. RileyMediacurrent Consultant

@andrewmriley

http://j.mp/rrpq2R