[GIS] How to share accurate location with Geodjango

geodjangopostgispostgresql

I am new to GIS and have been working on a webapp for location sharing. I want to be able to have my users be able to "Pin" their location in a map. For this I installed Geodjango/PostgreSQL/Postgis did the Geodjango tutorial and have a fully working map.

My problem is that I am not sure what the next step should be to be able to get the request the user's information (their location) when they decide to "pin" the location and be able to accurately put it on the map.

I am using django 1.11

Best Answer

You will need to build two parts to record user locations:

  • A front end solution, probably including a javascript based map (for example, by using leaflet or google maps) and the HTML5 geolocation API (Example here). Eventually this will create an HTTP/XHR call to your server (use HTTP POST) with your user's location details.
  • A Django view that accepts this call and records the location and the user information. You would probably want to save this info in a Django model with a PointField field.

Good luck!