Tue
Mar 31st

Introduction to Building Apps with OpenStreetMap

OpenStreetMap is an open source initiative that offers similar technology to Google Maps.  To really get the most out of OSM you should start by running the server locally and checking out their code.

Running OpenStreetMap

The frontend for OpenStreetMap is a Ruby on Rails application.  OSM refers to this as The Rails Port, and they have detailed documentation for installation.

It depends on RMagick for generating graphics, which means you’ll have to install ImageMagick to get it working.  This can be difficult on some platforms — if you’re using Mac OS I recommend installing ImageMagick with MacPorts.

Code is distributed using Subversion, and can be downloaded with the svn command:

svn co http://svn.openstreetmap.org/sites/rails_port

You’ll need to edit config/database.yml to set up a database.  It’s probably best to use MySQL rather than sqlite because it’s the one OSM recommend, and some databases don’t provide features geocoding software often requires.

Next, rake db:migrate and if you’ve got the required gems installed it should set up the database for you.

If any gems are the incorrect version, install them using the -v flag, for example:

sudo gem install -v=0.9.93 composite_primary_keys

Once the database migrations have run, edit config/environments/development.rb and add:

ENV['RAILS_ASSET_ID'] = ''

Next, start script/server and visit http://localhost:3000.

Running a Tile Server

The Rails app uses tiles from openstreetmap.org.  It’s possible to run your own tile server instead: detailed instructions can be found in Build Your Own OpenStreetMap Server.

Embedding the Map

You could edit a view in the Rails app to make a suitable page for an iframe, similar to this article: Creating Easy Map Embedding.

Web API

The Rails app has several APIs: OpenStreetMap APIs.

Comments (View)
Related Posts Widget for Blogs by LinkWithin