From 6408a1151c714c31a285e726a2a020b186ab89cf Mon Sep 17 00:00:00 2001 From: fkloft Date: Sun, 23 Mar 2014 21:23:06 +0100 Subject: [PATCH] [plugins/bookmarks-by-zaso] audo draw: show distance between selected portals /cc @ZasoGD --- plugins/bookmarks-by-zaso.user.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index 5a6ab61c..54164f42 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -675,6 +675,35 @@ } } + window.plugin.bookmarks.autoDrawCalcDistance = function() { + var latlngs = []; + var uuu = $('#bkmrksAutoDrawer a.bkmrk.selected').each(function(i) { + var tt = $(this).data('latlng'); + latlngs[i] = tt; + }); + + var distance = null; + if(latlngs.length == 2) { + distance = L.latLng(latlngs[0]).distanceTo(latlngs[1]); + } + + $('#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'; + + $('
') + .html(text) + .attr('id', 'bkmrksAutoDrawerDistance') + .appendTo('#bkmrksAutoDrawer'); + } + } + window.plugin.bookmarks.dialogLoadList = function() { var r = 'The "Draw Tools" plugin is required.'; @@ -724,7 +753,9 @@ + '' + ' Clear selection after drawing' + '

You must select 2 or 3 portals.

' + + '
' + element + + '
' + '
'; } return r;