Skip to content

Mapping and Geolocation in Ruby on Rails

Paulo Belo edited this page Sep 23, 2018 · 4 revisions

Resources for Understanding how to Geocode and Map a location

This is a work in progress. If you have any links to resources that might be helpful, add them!

"Geocoding" means to take information that represents a place (ex: an address) and get the latitude and longitude coordinates for it.

"Reverse geocoding" really is the reverse of that: given a latitude and longitude, get the address.

There are services that will provide that information. (Google is one such service). You need a way to send a message to the service and then deal with the information it sends back.

"Mapping" = display a location on a map. The map might be 'static' (you can't zoom or move around ['pan'] with it) or 'dynamic' (you can zoom in and out and pan around)

Main gems to use / consider:

Geocoder gem

http://www.rubygeocoder.com/

https://github.com/alexreisner/geocoder

Easily do geocoding and reverse geocoding. You can specify the service you want to use. Will also automagically compute distances and places "nearby".

GeoMaps4Rails gem

https://github.com/apneadiving/Google-Maps-for-Rails

Easily display Google maps. Uses Javascript to display maps. You can easily customize markers, display polygons, lines, etc.

Resources, Tutorials, Examples:

A good basic tutorial: https://www.sitepoint.com/geocoder-display-maps-and-find-places-in-rails/

Free RailsCast episode: http://railscasts.com/episodes/273-geocoder

Simple tutorial for German address geolocating with Google: http://larsgebhardt.de/advanced-geocoding-with-ruby-on-rails/

  • is in English
  • shows how to get the suburb name based on the sublocality info returned from Google, and county name based on administrative_area_level_3

A few tips: http://hankstoever.com/posts/11-Pro-Tips-for-Using-Geocoder-with-Rails

Another basic tutorial, mostly focusing on displaying maps:

https://anadea.info/blog/how-to-integrate-google-maps-into-ruby-on-rails-app

A Basic step-by-step tutorial with a CRUD App example

https://medium.com/@pjbelo/using-google-maps-api-v3-with-rails-5-2-b066a4b2cf14

Working examples:

CraftAcademy projects:

http://slow-food-august.herokuapp.com/

https://github.com/thesuss/sf-online-august

http://garden-club.herokuapp.com/users/1/profile

AgileVentures:

LocalSupport ? (others?)

Clone this wiki locally