From 1d8279243de99e68b16cbc0d572a57a4e7ce3a1e Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Thu, 13 Feb 2020 18:35:20 +0100 Subject: [PATCH] genPOI: polyline text improvements Don't require text for polylines/polygons, and support hovertext by utilising leaflet's tooltips. --- overviewer_core/aux_files/genPOI.py | 5 +++-- overviewer_core/data/js_src/util.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) mode change 100755 => 100644 overviewer_core/aux_files/genPOI.py diff --git a/overviewer_core/aux_files/genPOI.py b/overviewer_core/aux_files/genPOI.py old mode 100755 new mode 100644 index 4c84d10..0e88ea8 --- a/overviewer_core/aux_files/genPOI.py +++ b/overviewer_core/aux_files/genPOI.py @@ -410,13 +410,14 @@ def create_marker_from_filter_result(poi, result): d.update(dict(text=result[1], hovertext=result[0])) # Dict support to allow more flexible things in the future as well as polylines on the map. elif isinstance(result, dict): - d['text'] = result['text'] + if 'text' in result: + d['text'] = result['text'] # Use custom hovertext if provided... if 'hovertext' in result: d['hovertext'] = str(result['hovertext']) else: # ...otherwise default to display text. - d['hovertext'] = result['text'] + d['hovertext'] = result.get('text', '') if "icon" in result: d["icon"] = result['icon'] diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index 507bce9..5a4c9fe 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -404,6 +404,9 @@ overviewer.util = { fill: db['fill'] }; layerObj = db['isLine'] ? L.polyline(plLatLng, options) : L.polygon(plLatLng, options); + if (db['hovertext']) { + layerObj.bindTooltip(db['hovertext'], {sticky: true}); + } // TODO: add other config options (fill color, fill opacity) } else { // Convert coords @@ -414,7 +417,7 @@ overviewer.util = { layerObj = new L.marker(latlng, {icon: m_icon, title: db.hovertext}); } // Add popup to marker - if (marker_entry.createInfoWindow) { + if (marker_entry.createInfoWindow && db.text) { layerObj.bindPopup(db.text); } // Add the polyline or marker to the layer