Geolocation coordinate directly to database without using localStorage

Hei.

I'm using geolocation service and are trying to store coordinates directly to a database with javascript, without using localStorage. The point is to have a service that lists multiple markers to the map from stored coordinates. I manage to list out the coordinates, but cant figure out how to store coordinates directly to database first.
Any suggestions?

Thanks!
1 person has
this question
+1
This topic is no longer open for comments or replies.
  • Hello Roy,

    Could you please detail, where do you want to save them? In a column of type geopoint?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • Hello.

    Yes, in one Lat and one Lng column of geopoint type.

    I'm using this to show result on map:

    //Hvor "map_panel3Topper" er kart component navn.
    var map = Appery("map_panel3Topper").options.mapElement.gmap('get', 'map');
    var CreateMarker = function(data){
    console.log("add marker with coordinates = " + data.lat + " = " + data.long);

    var marker = new google.maps.Marker({
    position: new google.maps.LatLng(data.lat, data.long),
    map: map,
    });

    //Lag infovinduet.
    var infowindow = new google.maps.InfoWindow({
    content: '',
    maxWidth: 320
    });

    //Legg til en hendelse som skal åpne infovinduet.
    google.maps.event.addListener(marker, 'click', function() {

    //Sett hva som skal vises i infovinduet fra databasen.
    infowindow.setContent('' + data.tidspunkt + '');

    //Åpne infovindu.
    infowindow.open(map, marker);
    });
    };

    for (var i = 0; i < data.length; i++)

    //I denne funksjon bør du sette latitude, longitude og tekst som skal vises i infovinduet.
    CreateMarker({lat: data[i].Lat, long: data[i].Lng, tidspunkt: data[i]._createdAt});
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • Hi Roy,

    Yes you can use for this goal "create" service.

    If you want to store geolocation result to db you can follow this:

    1 on geolocation service "success" add JS event handler:

    2 inside this "success" event handler you can invoke "create" service to store results.



    //You should replace this values with values from geolocation response.
    var lat = 13;
    var long = 43;
    createServiceDataSource.execute({body: {lat: lat, long: long } });



    Also you should adjust this code in accordance to your case.

    Regards.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned