Vote count:
0
I have an array of javascript elements. Each element contains an address and a unique id.
var elements =
[
{
id: 1,
address: "address1"
},
{
id: 2,
address: "address2"
}
];
Element addresses are geocoded and resulting markers are displayed in a Google Map, as indicated in this post.
for (var i = 0; i < elements.length; i++) {
$.getJSON('http://ift.tt/1dMgVj6'+elements[i].address+'&sensor=false', null, function (data) {
// add marker to map
console.log(data.results[0]);
});
}
Now my goal is to associate each marker with the proper request. For example, suppose that the first geocoding (id=1) results in a marker positioned at (lat: 15.0526206, lng: 19.6929845). I would like to find a way to associate this marker with id=1 element.
I've tried to log data result (see snippet above), but unfortunately it doesn't help (formatted_address is similar to original element address but formatted differently, so string comparion is not feasible). How can I do?
asked 38 secs ago
Associate markers with proper request in multiple geocoding
Aucun commentaire:
Enregistrer un commentaire