From 9352d9af15f5e1419cd8e4b59c1234be5a1a4a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 21 Mar 2020 13:49:46 +0100 Subject: [PATCH] GeoInfo: while tab is active, show crosshair over map view center --- img/crosshair.png | Bin 0 -> 235 bytes src/GeoInfo.js | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 img/crosshair.png diff --git a/img/crosshair.png b/img/crosshair.png new file mode 100644 index 0000000000000000000000000000000000000000..fd33eaa3776eea1180593e3b74bea984bcba92d7 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^q9Dw{1|(OCFP#RY*pj^6T^Rm@;DWu&Cj&(|3p^r= z85p>QL70(Y)*K0-AbW|YuPggwPFY5E4cV)4;y@wU%#er@=ltB<)VvZPmw~~#C^fMp zHASI3vm`^o-P1Q9MK6^dDDLm+;uvCa`facy7lQ)Nti}K9Z{}T83}_NOXtR3u0zuXW zXQh*>3`^ABzHa!N8FnQ9a{IFA)qCazX?)AGy0fsV;#0t#LSg^H>SejV4*Pf;FwQVj UQW8)*zZGPsr>mdKI;Vst02+TuX#fBK literal 0 HcmV?d00001 diff --git a/src/GeoInfo.js b/src/GeoInfo.js index d807d4da..c60c59a1 100644 --- a/src/GeoInfo.js +++ b/src/GeoInfo.js @@ -22,6 +22,22 @@ register_hook('init', function () { updateTabHeader(tab.header) tab.header.title = lang('geoinfo:header') + let crosshairIcon = L.icon({ + iconUrl: 'img/crosshair.png', + iconSize: [21, 21], + iconAnchor: [10, 10], + }) + + let crosshair = new L.marker([0,0], { + icon: crosshairIcon, + clickable:false, + pane: "crosshair800" + }) + + global.map.createPane('crosshair800') + global.map.getPane('crosshair800').style.zIndex = 800 + global.map.getPane('crosshair800').style.pointerEvents = 'none' + let domZoom = document.createElement('div') domZoom.className = 'zoom' domZoom.title = lang('geoinfo:zoom') @@ -63,6 +79,8 @@ register_hook('init', function () { } function updateMapView () { + crosshair.setLatLng(global.map.getCenter()) + let scale = formatUnits.distance(global.map.getMetersPerPixel()) let scale2 = formatUnits.area(Math.pow(global.map.getMetersPerPixel(), 2)) let precision = getPrecision() @@ -131,6 +149,8 @@ register_hook('init', function () { global.map.on('locationfound', saveLocation) tab.on('select', () => { + crosshair.addTo(global.map) + updateMapView() updateLocation() @@ -142,6 +162,8 @@ register_hook('init', function () { }) tab.on('unselect', () => { + crosshair.removeFrom(global.map) + global.map.off('move', updateMapView) global.map.off('mousemove', updateMouse) global.map.off('mouseout', removeMouse)