Move OverlappingMarkerSpiderfier from player-tracker to core. Implement for bookmarks and draw tools

(Markers added to OMS shouldn't use the "click" event but "spiderfiedclick")
This commit is contained in:
fkloft
2014-06-09 21:08:06 +02:00
parent 7f26f8b6a8
commit d3fca8612c
5 changed files with 66 additions and 23 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) {}

25
code/oms.js Normal file
View File

@ -0,0 +1,25 @@
/*
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();
});
}