From 9bcf2d55428e0466e0d788563ccb9f9bec3bf3b4 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Tue, 12 Jul 2016 18:24:01 +0200 Subject: [PATCH] Re-implement location marker Click to centre, right-click to dismiss. --- overviewer_core/data/js_src/util.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index bbcfba4..dd2009a 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -122,6 +122,9 @@ overviewer.util = { // Set the background colour document.getElementById("mcmap").style.backgroundColor = ovconf.bgcolor; + if (overviewer.collections.locationMarker) { + overviewer.collections.locationMarker.remove(); + } // Remove old spawn marker, add new one if (overviewer.collections.spawnMarker) { overviewer.collections.spawnMarker.remove(); @@ -677,10 +680,22 @@ overviewer.util = { overviewer.map.setView(latlngcoords, zoom); - - // TODO re-add this - //var locationmarker = new overviewer.views.LocationIconView(); - //locationmarker.render(); + if (ovconf.showlocationmarker) { + /// TODO: Retina Icon + var locationIcon = L.icon({ + iconUrl: overviewerConfig.CONST.image.queryMarker, + }); + var locationm = L.marker(latlngcoords, { icon: locationIcon, + title: "Linked location"}); + overviewer.collections.locationMarker = locationm + overviewer.collections.locationMarker.on('contextmenu', function(ev) { + overviewer.collections.locationMarker.remove(); + }); + overviewer.collections.locationMarker.on('click', function(ev) { + overviewer.map.setView(ev.latlng); + }); + overviewer.collections.locationMarker.addTo(overviewer.map); + } }, /** * Generate a function to get the path to a tile at a particular location