Inserting HTML5 Coordinates Into Django Form

73 views
Skip to first unread message

DF

unread,
May 21, 2012, 2:10:35 PM5/21/12
to django...@googlegroups.com
I'm wading – carefully – into some basic geolocation using HTML5. I currently have a meta form that has space for lat and long coordinates and have found the proper code to obtain those coordinates using the Google Maps API (pretty simple stuff).

Next step: inserting those coordinates automatically into the form. The application would ideally allow users to make posts and store their coordinates for future reference and filtering (this is a big endeavor one step at a time).

I haven't yet explored mixing JavaScript with Django in this manner and was looking to see if there's a straightforward manner for doing this. Any resources, experience or expertise on this would be greatly appreciated. In the end, for context's sake, I would like users to have the ability to search for localized posts via the map and have the posts corresponding to the area display on screen.

Thanks for any insight.

Timothy Makobu

unread,
May 22, 2012, 9:36:26 AM5/22/12
to django...@googlegroups.com
If I understood your question correctly, using jQuery, I would use GMAP3 http://gmap3.net/ to get the the lat and long, store those in hidden form fields, and submit that. http://www.electrictoolbox.com/jquery-get-set-form-values/

MaxMind also have a free IP-to-City database, so pygeoip.GeoIP().record_by_addr(request.META["REMOTE_ADDR"])['city'] tells you the city of the client. (they are not exactly chained like that, but you get the idea)

my Ksh 0.02


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/CkxAVz64tgQJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages