Page 1 of 1
Multiple markers from json on Gmap
Posted: Thu May 08, 2014 5:56 pm
by Marcel Popescu
Hi,
I'm trying to add multiple markers on a Gmap from a remote json, with no success.
What I did is to create the service to get the json data, to create the data source, to add the following javascript to the service success event :
var coordsArray = data.markers;
var marker;
for (var i = 0, j = coordsArray.length; i < j; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng( coordsArray.latitude, coordsArray.longitude ),
map: Appery("googlemap_2").gmap
});
}
and finally to invoke the service with button click event in the design section.
Could you please give me a hand with this problem ?
Thanks,
Marcel
Multiple markers from json on Gmap
Posted: Thu May 08, 2014 6:31 pm
by Kateryna Grynko
Hi Marcel,
Here is an example of adding markers to map:
http://docs.appery.io/tutorials/addin...
Multiple markers from json on Gmap
Posted: Thu May 08, 2014 8:47 pm
by Marcel Popescu
Hi Katya,
Thanks for your reply. I have already looked at the link you mentioned but unfortunately it doesn't help me. (It reads the lat, long from the device and the markers details are hardcoded).
What I need, as mentioned before, is to read the markers' info from a json (REST) and display them on the Gmap.
The code I used is the one sent before.
Could you please have a look into it an give me a hand ?
Thanks,
Marcel
Multiple markers from json on Gmap
Posted: Fri May 09, 2014 6:50 am
by Serhii Kulibaba
Hello Marcel,
It should help you:
pre
var coordsArray = data.markers;
var marker;
var map = Apperyio("gmap");
$(coordsArray).each(function(){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(this.latitude, this.longitude),
map: map
});
});
map.refresh();
/pre
Multiple markers from json on Gmap
Posted: Fri May 09, 2014 9:00 am
by Marcel Popescu
Hi Sergiy,
I added the following JS to the service success event:
var coordsArray = data.markers;
var marker;
var map = Apperyio("googlemap_2");
$(coordsArray).each(function(){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(this.latitude, this.longitude),
map: map
});
});
map.refresh();
and I invoke the service at the mobilebutton_8 click.
Unfortunately it still doesn't work.
Marcel
Multiple markers from json on Gmap
Posted: Fri May 09, 2014 9:37 am
by Serhii Kulibaba
I found out the problem.
Use:
var map = Apperyio("googlemap_2");
instead of:
var map = Apperyio("googlemap_2").get(0);
Multiple markers from json on Gmap
Posted: Fri May 09, 2014 10:21 am
by Marcel Popescu
Sergiy, I didn't use ".get(0)" before. Anyway I tried in both ways and the behavior is the same. No marker shown.
Multiple markers from json on Gmap
Posted: Fri May 09, 2014 1:14 pm
by Marcel Popescu
Do you have any news on the above issue ?
Thanks,
Marcel
Multiple markers from json on Gmap
Posted: Fri May 09, 2014 1:17 pm
by Maryna Brodina
Hello Marcel!
Please post your public app link.
Multiple markers from json on Gmap
Posted: Fri Jun 27, 2014 10:27 am
by Kateryna Grynko
Hi Marcel,
Did you solve it?