Page 1 of 2

Adding Title to Multiple Location

Posted: Fri Dec 27, 2013 9:24 pm
by Ayman Gamal

I succeeded to implement this tutorial (Adding Multiple Location Points on Google Map with Appery.io Backend Services) and it runs correctly , but I need to add a Title from the database to the Markers. How can I do this?
I added new column to the addresses Table
Image


Adding Title to Multiple Location

Posted: Fri Dec 27, 2013 9:52 pm
by maxkatz

Please check Google Maps API. The Marker should have a property where you can set its title/name.


Adding Title to Multiple Location

Posted: Fri Dec 27, 2013 11:24 pm
by Ayman Gamal

I checked Google map Api and i found "title" property but i can not send it to (ConvertAddr" service parameters) to get place in the loop in this code:

function log2(m) {
return ((Math.log(m)) / (Math.log(2)));
};
for (var k in value.geometry) {
if (locationHelper.checkLocation(k)) {
locationHelper.aLocations.push([value.geometry.location.lat, value.geometry.location.lng]);
}
}
var maxLatitude = -90,
minLatitude = 90,
maxLongitude = -180,
minLongitude = 180;
for (i = 0; i < locationHelper.aLocations.length; i++) {
maxLatitude = locationHelper.aLocations[0] maxLatitude ? locationHelper.aLocations[0] : maxLatitude;
minLatitude = locationHelper.aLocations[0] < minLatitude ? locationHelper.aLocations[0] : minLatitude;
maxLongitude = locationHelper.aLocations[1] maxLongitude ? locationHelper.aLocations[1] : maxLongitude;
minLongitude = locationHelper.aLocations[1] < minLongitude ? locationHelper.aLocations[1] : minLongitude;
}
var map = new google.maps.Map(document.getElementsByName("multiGoogleMap")[0], {
zoom: 5,
center: new google.maps.LatLng((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker, i;
for (i = 0; i < locationHelper.aLocations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locationHelper.aLocations[0], locationHelper.aLocations[1]),
map: map
});
}


Adding Title to Multiple Location

Posted: Sat Dec 28, 2013 2:14 am
by maxkatz

I'm not 100% sure I understand the question. You need to have the title information inside the loop, where you create the marker.


Adding Title to Multiple Location

Posted: Sat Dec 28, 2013 12:10 pm
by Ayman Gamal

Yes, Exactly


Adding Title to Multiple Location

Posted: Sat Dec 28, 2013 2:02 pm
by Ayman Gamal

I need to bring this "title" from my Database:

Image


Adding Title to Multiple Location

Posted: Sat Dec 28, 2013 3:44 pm
by Igor

Hello,

You should create service which will return title from database. Save service responce into localStorage variable. After that you can use localStorage value as marker title value. Below doc should be helpful: http://docs.appery.io/documentation/r...


Adding Title to Multiple Location

Posted: Sat Dec 28, 2013 5:09 pm
by Ayman Gamal

The title already comes in the same "Locations_addresses_list_service" as in the following picture:
Image

and this the code for locationList variable:
Image

var map = Appery('multiGoogleMap');
var aLocations = new Array();
aLocations.push(value);
if (value) {
for (var i in value) {
if(i == 'location') {
getCoords.execute({
'data' : {
'address' : value.location,
'sensor' : true,
'title' : value.title
}
});
}
}
}


Adding Title to Multiple Location

Posted: Sat Dec 28, 2013 5:13 pm
by Ayman Gamal

but I can not receive the "title" value in getCoords service


Adding Title to Multiple Location

Posted: Mon Dec 30, 2013 8:09 am
by Oleg Danchenkov

Hi Ayman.
I think you should use generic service for ConvertAddr service (instead of common REST service) and pass 'title' to this service.
https://getsatisfaction.com/apperyio/...