Hi Shazia,
You can make a XHR (Ajax) request in javascript to send the data to a
django callback.
HTH,
Etienne
Le 2018-02-12 à 18:04, Shazia Nusrat a écrit :
Hi,
Below is the code for Javascript from Django template Google Maps API.
I need to be able to save this in my Django models with JSON response.
I am new user so an example will be really a great help.
Precisely I need to be able to save coordinates like latitude and
longitude and then convert it to an address.
Thanks
varmap,infoWindow;functioninitMap(){ map
=newgoogle.maps.Map(document.getElementById('map'),{
center:{lat:-34.397,lng:150.644}, zoom:6}); infoWindow
=newgoogle.maps.InfoWindow;// Try HTML5
geolocation.if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){varpos ={
lat:position.coords.latitude,
lng:position.coords.longitude };
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
infoWindow.open(map); map.setCenter(pos);},function(){
handleLocationError(true,infoWindow,map.getCenter());});}else{//
Browser doesn't support Geolocation
handleLocationError(false,infoWindow,map.getCenter());}}functionhandleLocationError(browserHasGeolocation,infoWindow,pos){
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?'Error: The Geolocation
service failed.':'Error: Your browser doesn\'t support
geolocation.'); infoWindow.open(map);}
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAD83tOzabkiPgniqofN6BH2tLogeiGE9JaZ5rppi3f44Hb0ybA%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAD83tOzabkiPgniqofN6BH2tLogeiGE9JaZ5rppi3f44Hb0ybA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/e87c4a18-519e-5264-00cb-65d3203048bd%40yandex.com.
For more options, visit https://groups.google.com/d/optout.