Page 2 of 2

Adding Title to Multiple Location

Posted: Mon Dec 30, 2013 6:48 pm
by Ayman Gamal

Thanks Oleg, but the function of "ConvertAddr" service is to send the addresses from my database to (https://maps.googleapis.com/maps/api/...) and return (address_components - geometry -types.....) and all these result saved in (converted) Java script variable:
Image

and this is the code in the (converted) Java script variable:

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: 30,
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: Mon Dec 30, 2013 6:51 pm
by Ayman Gamal

so I need to add the title at the end of this code to be to be a bundle with the Map Marker


Adding Title to Multiple Location

Posted: Mon Dec 30, 2013 8:46 pm
by Kateryna Grynko

Hi Ayman,

Right after codemap: map/code add the following code:pretitle: "text"/preReplace 'text ' with any text you need. Don't forget to add a comma after codemap: map/code


Adding Title to Multiple Location

Posted: Wed Jan 01, 2014 10:34 am
by Ayman Gamal

Thanks Katya, This is what I've done already in the third comment.
But I need to bring this "title" from my Database.That's what I try to ask from the beginning.

Image


Adding Title to Multiple Location

Posted: Thu Jan 02, 2014 3:42 pm
by Kateryna Grynko

Hi Ayman,

You can use the same approach for both value.geometry.location and value.text (go through all the array items).


Adding Title to Multiple Location

Posted: Tue May 20, 2014 4:59 pm
by sowmen choudhury

Well I am not sure if I followed the solution here, Katya can you explain a bit I have same issue and I am struggling.

Thanks in advance...


Adding Title to Multiple Location

Posted: Wed May 21, 2014 11:54 am
by Evgene Karachevtsev

Hello,

You also should push to array title:

locationHelper.aLocations.push([value.geometry.location.lat, value.geometry.location.lng,value.title]);
(instead of this code: ocationHelper.aLocations.push([value.geometry.location.lat, value.geometry.location.lng]);
)

Then in the part where markers are created add this code after "map: map," :

title: locationHelper.aLocations[2]