[OpenLayers-Users] olhttp: Integration of Django and OpenLayers

christopher.schmidt at nokia.com christopher.schmidt at nokia.com
Thu Sep 15 11:18:21 EDT 2011


Hi,

Over the last couple weeks, I've been doing a little bit of work on a Django
application designed to show how to use OpenLayers for editing in an application.

The code is available from:

  https://github.com/crschmidt/olhttp/

The code demonstrates a couple things:

 1. How to create a simple server-side GeoDjango application which supports simple
    output as GeoJSON, giving explicit URLs to data objects and using GeoJSON as input
    output. (This is essentially FeatureServer, ported to GeoDjango as a backend;
    it uses the core components of FeatureServer for Django feature reading and GeoJSON
    writing.)

 2. It implements an easy-to-customize editing interface for OpenLayers, which supports
    simple entry of attributes, and uses Protocol.HTTP, Protocol.Save, and OpenLayers
    Layer/Protocol/Format support to do all of the heavy lifting.

I've deployed a branch of this code set up specifically to target tablet/mobile-based 
editing at http://olhttp.djangozoom.com/ out of the 'djangozoom' branch of that tree.

The key OpenLayers component of this is:

  https://github.com/crschmidt/olhttp/blob/18cd2f42da28bede88e7e407b60a0e5851ab59f1/main/static/js/olhttp.js

This code is designed to be reusable -- it shouldn't generally need to be modified 
a ton for a given application. (In order to take the code I implemented for olhttp
on a desktop, and modify it for the tablet, the only thing I ended up changing 
was the zoomToExtent() line.)

So, if you have ever wanted to implement *any* of:
 - Display of multiple features from a Django-based backend
 - Drawing of features in a map, with automatic saving of features to a backend
 - Simple editing of attributes using HTML forms

I would recommend checking out olhttp.

(Pull requests welcome.)

-- 
Christopher Schmidt
Nokia


More information about the Users mailing list