Page 1 of 1

What is the easiest way of saving a geolocation service output (lat and long) into a DB as a geopoint?

Posted: Thu Apr 03, 2014 12:50 am
by pboloz

I had a look at ALL the related posts, but could not understand it as I am a newbie to Javascript. I know how to capture and map this data to be displayed, but how to send it straight to my geopoint field in DB?

Image

Please don't send me to a tutorial. Thank you!


What is the easiest way of saving a geolocation service output (lat and long) into a DB as a geopoint?

Posted: Thu Apr 03, 2014 12:51 am
by pboloz

Oh, and by the way. I already have a DB set up with geopoint column in geopint format.


What is the easiest way of saving a geolocation service output (lat and long) into a DB as a geopoint?

Posted: Thu Apr 03, 2014 4:42 am
by Illya Stepanov

Hi --

To save geo point in DB with geoPoint type you should do:
ol
liCreate update service./li

liNavigate to data tab./li

liClick "Edit mappings"./li

liNavigate to the "Request" tab./li

liFind your geoLocation field parameter. And click "Add JS"/"Edit JS"./li

liJS Editor appears. Insert the following code:
precode
//You should change these constants to your dynamic data. For example using localStorage variables.
var latitude = "44&quot
var longitude = "12&quot
return [latitude, longitude];/code/pre
/li
/ol
That's all. After the update service invokes you will update your geoPoint field type with values you have passed to.

Regards.