Google maps: Autorizing multiple map
This commit is contained in:
parent
9eaec267fe
commit
3739c53542
|
|
@ -620,18 +620,37 @@ tarteaucitron.services.googlemaps = {
|
|||
"cookies": [],
|
||||
"js": function () {
|
||||
"use strict";
|
||||
var mapOptions,
|
||||
map,
|
||||
uniqIds = [],
|
||||
i;
|
||||
|
||||
if (tarteaucitron.user.googlemapsApiKey === undefined) {
|
||||
return;
|
||||
}
|
||||
tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=tarteaucitron_googlemaps&key=' + tarteaucitron.user.googlemapsApiKey);
|
||||
|
||||
tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=tac_googlemaps_callback&key=' + tarteaucitron.user.googlemapsApiKey);
|
||||
|
||||
window.tac_googlemaps_callback = function () {
|
||||
tarteaucitron.fallback(['googlemaps-canvas'], function (x) {
|
||||
var uniqId = '_' + Math.random().toString(36).substr(2, 9);
|
||||
uniqIds.push(uniqId);
|
||||
return '<div id="' + uniqId + '" zoom="' + x.getAttribute('zoom') + '" latitude="' + x.getAttribute('latitude') + '" longitude="' + x.getAttribute('longitude') + '" style="width:' + x.offsetWidth + 'px;height:' + x.offsetHeight + 'px"></div>';
|
||||
});
|
||||
|
||||
for (i = 0; i < uniqIds.length; i += 1) {
|
||||
mapOptions = {
|
||||
zoom: parseInt(document.getElementById(uniqIds[i]).getAttribute('zoom'), 10),
|
||||
center: new google.maps.LatLng(parseFloat(document.getElementById(uniqIds[i]).getAttribute('latitude'), 10), parseFloat(document.getElementById(uniqIds[i]).getAttribute('longitude'), 10))
|
||||
};
|
||||
map = new google.maps.Map(document.getElementById(uniqIds[i]), mapOptions);
|
||||
}
|
||||
};
|
||||
},
|
||||
"fallback": function () {
|
||||
"use strict";
|
||||
var id = 'googlemaps';
|
||||
|
||||
if (document.getElementById('tac_map-canvas')) {
|
||||
document.getElementById('tac_map-canvas').innerHTML = tarteaucitron.engage(id);
|
||||
}
|
||||
tarteaucitron.fallback(['googlemaps-canvas'], tarteaucitron.engage(id));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue