diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index abbe6dfb..cc9b45bc 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -744,6 +744,7 @@ } } }); + window.plugin.bookmarks.autoDrawOnSelect(); } window.plugin.bookmarks.draw = function(view) { @@ -787,38 +788,42 @@ map.fitBounds(layer.getBounds()); } } - else{ - $('#bkmrksAutoDrawer p').toggle().delay('2500').fadeOut('500'); - } } - window.plugin.bookmarks.autoDrawCalcDistance = function() { + window.plugin.bookmarks.autoDrawOnSelect = function() { var latlngs = []; var uuu = $('#bkmrksAutoDrawer a.bkmrk.selected').each(function(i) { var tt = $(this).data('latlng'); latlngs[i] = tt; }); - var distance = null; + var text = "You must select 2 or 3 portals!"; + var color = "red"; + + function formatDistance(distance) { + var text = digits(distance > 10000 ? (distance/1000).toFixed(2) + "km" : (Math.round(distance) + "m")); + return distance >= 200000 + ? ''+text+'' + : text; + } + if(latlngs.length == 2) { - distance = L.latLng(latlngs[0]).distanceTo(latlngs[1]); + var distance = L.latLng(latlngs[0]).distanceTo(latlngs[1]); + text = 'Distance between portals: ' + formatDistance(distance); + color = ""; + } else if(latlngs.length == 3) { + var longdistance = false; + var distances = latlngs.map(function(ll1, i, latlngs) { + var ll2 = latlngs[(i+1)%3]; + return formatDistance(L.latLng(ll1).distanceTo(ll2)); + }); + text = 'Distances: ' + distances.join(", "); + color = ""; } - $('#bkmrksAutoDrawerDistance').remove(); - if(distance !== null) { - distance = Math.round(distance); - - var text = 'Distance between portals: '; - if(distance > 1000) - text += digits(distance / 1000) + 'km'; - else - text += digits(distance) + 'm'; - - $('
You must select 2 or 3 portals.
' - + 'You must select 2 or 3 portals!
' + + '