DeveloperGuidelines = GIS Module = == How to add a new Layer type == === Model === {{{models/_gis.py}}} {{{ gis_layer_types=['newlayertype','...'] # Provide layer-specific options in it's own table: db.define_table('gis_layer_newlayertype', SQLField('modified_on','datetime',default=now), SQLField('layer',length=64), SQLField('field')) db.gis_layer_newlayertype.layer.requires=IS_IN_DB(db,'gis_layer.uuid','gis_layer.name') }}} === Controller === {{{controllers/gis.py}}} {{{ def update_layer(): # If form needs populating: elif type=="newlayertype": field = [""] subtype=0 options_subtype = [""] key=0 form=FORM( INPUT(_name="field"), # Could also be a SELECT ) if form.accepts(request.vars,session,keepvalues=True): elif type_new=="newlayertype": db(db['gis_layer_%s' % type_new].layer==t2.id).select()[0].update_record( field=form.vars.field ) def map_service_catalogue(): form=FORM( INPUT(_name="field"), # Could also be a SELECT ) if form.accepts(request.vars,session,keepvalues=True): elif type_new=="newlayertype": db['gis_layer_%s' % type_new].insert( layer=id, field=form.vars.field ) }}} If loading custom JS files when the new Layer is active: {{{ def map_viewing_client(): }}} === View === {{{views/gis/map_service_catalogue.html}}} {{{ {{if form.errors.field:}}
{{=form.errors.field}}
{{pass}} }}} {{{static/scripts/gis_layers.js}}} {{{ }}} {{{views/gis/map_viewing_client.html}}} ---- DeveloperGuidelines