-
Book Overview & Buying
-
Table Of Contents
Python Geospatial Development - Second Edition - Second Edition
By :
Now that we know which feature the user wants to edit, our next task is to implement the edit feature page itself. To do this, we are going to have to create a custom form with a single input field, named geometry, that uses a map-editing widget for editing the feature's geometry.
To create this form, we're going to borrow elements from GeoDjango's built-in "admin" interface, in particular the django.contrib.gis.admin.GeoModelAdmin class. This class provides a method named get_map_widget() which returns an editing widget which we can then include in a custom-generated form.
The process of building this form is a bit involved, thanks to the fact that we have to create a new django.forms.Form subclass on-the-fly to be handle the different types of geometries which can be edited. Let's put this complexity into a new function within the shared.utils module, which we'll call get_map_form().
Edit the utils.py module and type in the following code:
def get_map_form(shapefile): ...
Change the font size
Change margin width
Change background colour