Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

I would like to use this tutorial to add a multi marker map to my app. My issue is that I have the LatLong stored in the db not the address. Since i dont need to convert the address to the LatLong can you give me some advice on how to modify the tutorial?
adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hello Tommy!

Do you have any data instead of address ?

Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Yes, I will be using a appery database back end that has several records that each have two fields names Lat and Long. These will hold the lat and long from the geolocation service that is used on another part of the app.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hi Tommy,

You don't need all the tutorial example, you would need just to set markers based on the database values:
codemarker = new google.maps.Marker({
position: new google.maps.LatLng( Latitude_from_DB, Longitude_from_DB ),
map: Appery("map_name").gmap
});/code

ciccio
Posts: 0
Joined: Fri Jun 14, 2013 10:40 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

hi katya,
what should i do if i want to load a list of location with latitude and logitude collected from a REST service:
i have a rest service wich get a json like {
"coordinate":[
{
"latitudine":"39,3006",
"longitudine":"16.2546",
"descr":"cosenza"
},
{
"latitudine":"39.32883",
"longitudine":"16.24410",
"descr":"rende"
},

i tried to save this json into a local storage variale

Image

but if i add a button with a js like alert(localStorage.getItem('list_coordinate')); i get null

i tried to add a js to the local storage with "var aLocations = new Array();
aLocations.push(value);" but i got null.

Actually i would like to show on the map all the locations reported in the json so i would like to use the code you suggested in a loop wich get latitude and longitude from the json. How can i do it?

could you help me?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hi,

You shouldn't use mapping. You would need to process the first response parameter of Success event .

ciccio
Posts: 0
Joined: Fri Jun 14, 2013 10:40 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

thnks, i added the js "var response = JSON.stringify(data);
localStorage.setItem("list_coordinate", response);"
to the rest Success event. and i'm looking for how to
loop on the list_coordinate variable to use all the coordinates i stored instead of Latitude_from_DB, Longitude_from_DB in the code you suggested.

marker = new google.maps.Marker({
position: new google.maps.LatLng( Latitude_from_DB, Longitude_from_DB ),
map: Appery("map_name").gmap
});

do you have any suggestion?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

You should define an array with coordinates in your data structure, and place markers using cycle: codefor(var i; i < length_of_array; i++) { &#46;&#46;&#46; } /code
https://developer.mozilla.org/en-US/d...

ciccio
Posts: 0
Joined: Fri Jun 14, 2013 10:40 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

i'm sorry, but could you explain how to define an array with coordinates in my data structure.??

should i map the response json to a localStorage variable and then add a JS: "var aLocations = new Array();
aLocations.push(value);" ?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hello! You can run the following code on button click event:
codevar list_coordinate = localStorage&#46;getItem('list_coordinate');
var obj = JSON&#46;parse(list_coordinate);
var coordsArray = obj&#46;coordinate;
var marker;
for (var i = 0, j = coordsArray&#46;length; i < j; i++) {
marker = new google&#46;maps&#46;Marker({
position: new google&#46;maps&#46;LatLng( coordsArray&#46;latitudine, coordsArray&#46;longitudine ),
map: Appery("map_name")&#46;gmap
});
}/code
but please note that if you need to add markers on map after service is being invoked (without any additional events such as button click) you have to run this code on service Success event. This way there is no need to work with localStorage.

Return to “Issues”