Search code examples
pythondjangoopenlayersopenstreetmapgeodjango

Using Django as a map source for openlayer UI


I am thinking of creating a web application that shows a map of a city (from openstreetmaps data). I would like to create a layer on top which represents markers. I foresee that I will have a database of numerous markers, which will be shown on the map as layer. I have come across openstreetmap, openlayers, geodjango etc but am unable to figure out how to make all these fit together to solve my issue. I am comfortable using Django and Python. Can someone help me understand the following:

  1. How to host OSM data on my own server using Django and acting as a Mapserver (or map source) for openlayers?
  2. How to ask openlayer to talk to this server to render the map or overlays?

I'm sorry if some part of my question does not make sense; it is because my understanding how these components is quite hazy at the moment.


Solution

  • Displaying markers at coordinates is the easy part. The harder part is hosting your own base map. Here is one way I think you could do it:

    1. Obtain the OpenStreetMap data for the area you are interested in.
    2. Develop a stylesheet for your map, or use an existing one. Mapnik is an option.
    3. Use Tilecache to serve cached image tiles of the map at various scale levels. This would have to run in addition to your django app.

    Another option would be to use Tiledrawer to set up an Amazon EC2 server serving your base map without having to manually configure everything.

    Stack Overflow is only letting me post two links, so you will have to search for the websites of Tilecache and Mapnik, but they are easy to find.

    References: