This commit is contained in:
Jon Atkins
2014-06-13 21:59:14 +01:00
5 changed files with 69 additions and 26 deletions

View File

@ -560,6 +560,7 @@ function boot() {
window.setupStyles();
window.setupDialogs();
window.setupMap();
window.setupOMS();
window.setupGeosearch();
window.setupRedeem();
window.setupLargeImagePreview();
@ -657,6 +658,7 @@ try { console.log('Loading included JS now'); } catch(e) {}
// contains the default Ingress map style.
@@INCLUDERAW:external/Google.js@@
@@INCLUDERAW:external/autolink.js@@
@@INCLUDERAW:external/oms.min.js@@
try { console.log('done loading included JS'); } catch(e) {}

41
code/oms.js Normal file
View File

@ -0,0 +1,41 @@
/*
OMS doesn't cancel the original click event, so the topmost marker will get a click event while spiderfying.
Also, OMS only supports a global callback for all managed markers. Therefore, we will use a custom event that gets fired
for each marker.
*/
window.setupOMS = function() {
window.oms = new OverlappingMarkerSpiderfier(map, {
keepSpiderfied: true,
legWeight: 3.5,
legColors: {
usual: '#FFFF00',
highlighted: '#FF0000'
}
});
window.oms.addListener('click', function(marker) {
map.closePopup();
marker.fireEvent('spiderfiedclick', {target: marker});
});
window.oms.addListener('spiderfy', function(markers) {
map.closePopup();
});
map._container.addEventListener("keypress", function(ev) {
if(ev.keyCode === 27) // Esc
window.oms.unspiderfy();
}, false);
}
window.registerMarkerForOMS = function(marker) {
marker.on('add', function () {
window.oms.addMarker(marker);
});
marker.on('remove', function () {
window.oms.removeMarker(marker);
});
if(marker._map) // marker has already been added
window.oms.addMarker(marker);
}