Plugin providing a Location picker widget for geometry fields

97 views
Skip to first unread message

Leonel Câmara

unread,
Aug 14, 2014, 11:52:57 PM8/14/14
to web...@googlegroups.com
In 12 hours or so I'm going on a week long vacation, before I go, I thought this could be useful to some people here, even if just as an example, now that the DAL supports geo stuff.

This small plugin provides a location picker and a validator for geometry (NOT geography) fields that actually represent real points on the map.

The usage is quite simple and here's an example:

from plugin_location_picker import location_widget, IS_GEOLOCATION

db.define_table('point',
    Field('name'),
    Field('coord', 'geometry()', requires=IS_GEOLOCATION(), widget=location_widget())
)

Here's a more complex example that makes the map start in the center of Lisbon (Everyone should use this):

from plugin_location_picker import location_widget, IS_GEOLOCATION

db.define_table('point',
    Field('name'),
    Field('coord', 'geometry()', requires=IS_GEOLOCATION(), widget=location_widget(map_options={'center': {'lat': 38.725275, 'lng': -9.150028}}, marker_options={'position': {'lat': 38.725275, 'lng': -9.150028}}))
)

Finally, go to appadmin and add points to your point table, verify that you now have an awesome widget (well the bootstrap 3 classes probably need improvement so the appearance may be odd).

Also, remember to make sure your backend is one of those supported by the geoDAL sqlite/spatialite postgres/postgis or mssql. I actually only tested this with postgresql and postgis so results may vary.

Respect the BEER-WARE license please.
web2py.plugin.location_picker.w2p

Donald McClymont

unread,
Sep 22, 2016, 5:56:15 PM9/22/16
to web2py-users
Just for reference I have hacked about with this a bit at the following link:


It now provides an example app with  reverse geocoding, ability to pickup users location per html5 and a method of working with non-geospatial databases by moving the result to separate latitude and longitude - however some of that is not strictly plugin and would need a bit more incorporation.  Doubtless there are better ways of doing this but as far as I can see what is there does work.

Donald
Reply all
Reply to author
Forward
0 new messages