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

Adding Title to Multiple Location

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

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

Adding Title to Multiple Location

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

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

Adding Title to Multiple Location

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

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

Adding Title to Multiple Location

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

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

Adding Title to Multiple Location

Hi Ayman,

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

sowmen choudhury
Posts: 0
Joined: Sat Feb 01, 2014 3:32 pm

Adding Title to Multiple Location

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Adding Title to Multiple Location

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]

Return to “Issues”