Geolocation in Drupal


Published on

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

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Geolocation in Drupal

  1. 1. Geolocation in Drupal (nodes & users) By Andrew M. Riley Mediacurrent Consultant @andrewmriley
  2. 2. Goal <ul><li>Introduce users to basic mapping concepts, OpenLayers configuration in Drupal and Geocoding users based off of IP address or device location. </li></ul><ul><li>Disclaimer: Getting fancy may require some type of programming knowledge. </li></ul>
  3. 3. Mapping in General  
  4. 4.   <ul><li>GIS </li></ul><ul><li>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. </li></ul><ul><li>Source: </li></ul>
  5. 5.   <ul><li>Geolocation </li></ul><ul><li>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. </li></ul><ul><li>Source: </li></ul>
  6. 6.   <ul><li>Geocoding </li></ul><ul><li>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 Systems </li></ul><ul><li>Source: </li></ul>
  7. 7. Recap <ul><li>GIS  - System for mapping points and interacting with points. </li></ul><ul><li>Geolocation  - Real world location of an object represented as coordinates. Could be the action of looking up or the stored values. </li></ul><ul><li>Geocoding - The action of looking up coordinates to map real world objects. </li></ul>
  8. 8. Creating a map  
  9. 9. The GMap Way <ul><li>Location Module + GMap </li></ul>
  10. 10. The OpenLayers Way <ul><li>OpenLayers </li></ul><ul><li>+ </li></ul><ul><li>Geocode </li></ul><ul><li>+ </li></ul><ul><li>Geofield </li></ul>
  11. 11. OpenLayers (map display) <ul><ul><li>Manages information about the maps (not points) </li></ul></ul><ul><ul><li>Displays Maps </li></ul></ul><ul><ul><li>Integrates with views </li></ul></ul>
  12. 12. Geofield (storage) <ul><ul><li>Creates a new field type </li></ul></ul><ul><ul><li>Flexible Output </li></ul></ul><ul><ul><li>Ties in with Geocode module </li></ul></ul><ul><ul><li>Can display a map for users to select a location </li></ul></ul>
  13. 13. Geocode (lookup) <ul><ul><li>Converts addresses into lat/long </li></ul></ul><ul><ul><li>Uses the Geofield field type for storage </li></ul></ul><ul><ul><li>Pulls information from other fields </li></ul></ul><ul><ul><li>Can use different geocoding engines </li></ul></ul><ul><ul><li>Good user experience </li></ul></ul><ul><ul><li>Geocoding can be wonky outside of the U.S. </li></ul></ul>
  14. 14. OpenLayers Proximity <ul><ul><li>***There is currently no D7 version*** </li></ul></ul><ul><ul><li>Lets users search by distance </li></ul></ul><ul><ul><li>Uses view as its interface </li></ul></ul>
  15. 15. Locating your users  
  16. 16. Why? <ul><ul><li>Hide/Change options depending on which country the user is in </li></ul></ul><ul><ul><li>Redirect the user to a different version of the site </li></ul></ul><ul><ul><li>Better user identification </li></ul></ul><ul><ul><li>Better user experience </li></ul></ul>
  17. 17. How? <ul><ul><li>Find out the users IP Address </li></ul></ul><ul><ul><li>Lookup the IP Address somehow and find out the location data. </li></ul></ul><ul><ul><li>??? </li></ul></ul><ul><ul><li>Profit </li></ul></ul>
  18. 18. Three Questions <ul><ul><li>Will I be using this on mobile? </li></ul></ul><ul><ul><li>How much money do I want to spend? </li></ul></ul><ul><ul><li>Can I process the data at a later date? (and how much data) </li></ul></ul>
  19. 19. Google Loader <ul><li>Pros: </li></ul><ul><ul><li>Free </li></ul></ul><ul><ul><li>Returns more than just Lat & Long </li></ul></ul><ul><ul><li>Unlimited Queries </li></ul></ul><ul><ul><li>2-4-1 Loading of JQuery </li></ul></ul><ul><li>Cons: </li></ul><ul><ul><li>Not always reliable </li></ul></ul><ul><ul><li>Requires an external source </li></ul></ul><ul><ul><li>Mobile & International results unreliable </li></ul></ul>
  20. 20. HTML5 Geolocation <ul><li>Pros: </li></ul><ul><ul><li>Works great on mobile </li></ul></ul><ul><ul><li>Uses GPS if possible </li></ul></ul><ul><ul><li>Free </li></ul></ul><ul><li>Cons: </li></ul><ul><ul><li>Browser support is unreliable* </li></ul></ul><ul><ul><li>Asks the user if you can use their location </li></ul></ul><ul><ul><li>Only returns Lat & Long </li></ul></ul>
  21. 21. Pay Databases & Services <ul><li>Pros: </li></ul><ul><ul><li>Can be internal or external </li></ul></ul><ul><ul><li>Doesn't ask the user to use their location </li></ul></ul><ul><li>Cons: </li></ul><ul><ul><li>Can cost a lot of money </li></ul></ul><ul><ul><li>Could have limited number of queries </li></ul></ul><ul><ul><li>Might have the wrong location for mobile </li></ul></ul><ul><ul><li>International data varies on levels below country </li></ul></ul>
  22. 22. Which one to use? <ul><li>The right tool for the job + a backup method </li></ul><ul><li>or </li></ul><ul><li>Use the Smart IP module w/ Device Geolocation </li></ul><ul><li>($_SESSION['smart_ip']['location']) </li></ul>
  23. 23. Modules <ul><li>OpenLayers </li></ul><ul><li> </li></ul><ul><li>Geocode </li></ul><ul><li> </li></ul><ul><li>Geofield </li></ul><ul><li> </li></ul><ul><li>Smart IP </li></ul><ul><li> </li></ul><ul><li>Device Geolocation </li></ul><ul><li> </li></ul>
  24. 24. Pay IP Services <ul><li>MaxMind </li></ul><ul><li> </li></ul><ul><li>IP2Location </li></ul><ul><li> </li></ul><ul><li>IPInfoDB </li></ul><ul><li> </li></ul>
  25. 25. More Info <ul><li>OpenLayers (D6) Presentation by Patrick Hayes </li></ul><ul><li>(Far more technical than my talk) </li></ul><ul><li> </li></ul><ul><li>OpenLayers (D7) Docs </li></ul><ul><li> </li></ul><ul><li>OpenLayers (JS Library) </li></ul><ul><li> </li></ul>
  26. 26. Geolocation in Drupal (nodes & users) By Andrew M. Riley Mediacurrent Consultant @andrewmriley