Ayman Gamal
Posts: 0
Joined: Sun Oct 06, 2013 7:33 pm

Adding Title to Multiple Location

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Adding Title to Multiple Location

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

Ayman Gamal
Posts: 0
Joined: Sun Oct 06, 2013 7:33 pm

Adding Title to Multiple Location

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
});
}

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Adding Title to Multiple Location

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

Ayman Gamal
Posts: 0
Joined: Sun Oct 06, 2013 7:33 pm

Adding Title to Multiple Location

Yes, Exactly

Ayman Gamal
Posts: 0
Joined: Sun Oct 06, 2013 7:33 pm

Adding Title to Multiple Location

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

Image

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Adding Title to Multiple Location

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...

Ayman Gamal
Posts: 0
Joined: Sun Oct 06, 2013 7:33 pm

Adding Title to Multiple Location

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
}
});
}
}
}

Ayman Gamal
Posts: 0
Joined: Sun Oct 06, 2013 7:33 pm

Adding Title to Multiple Location

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

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

Adding Title to Multiple Location

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/...

Return to “Issues”