I have an object with location and description, the markers are well marked on the map but the title is always "gato". I tried several things like clousers, but it doesnt work or I havent used correctly. Nested for loop that cycles the object and it does get the location but not the description, which one is the all the time.Can anyone help me?This is my code:
/*OBJECT */
var addresses1 = {
"address_1": {
"location": "Avenida de burgos, 9, madrid",
"description": "gallina"
},
"address_2": {
"location": "castellana, 169, madrid",
"description": "pollo"
},
"address_3": {
"location": "bilbao, 5, madrid",
"description": "gato"
}
}
/* NEsted loop indie the intilize() method */
for (var key in addresses1) {
var obj = addresses1[key];
for (var y = 0; y < 1; y++) {
var locat = obj.location;
var descrip = obj.description;
var myAddressQuery = locat;
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': myAddressQuery}, function(results, status) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
icon: image,
position: results[0].geometry.location,
title: descrip
});
});
}
}