0

genPOI: polyline text improvements

Don't require text for polylines/polygons, and support hovertext
by utilising leaflet's tooltips.
This commit is contained in:
Nicolas F
2020-02-13 18:35:20 +01:00
parent 2c92b4acf9
commit 1d8279243d
2 changed files with 7 additions and 3 deletions

3
overviewer_core/aux_files/genPOI.py Executable file → Normal file
View File

@@ -410,13 +410,14 @@ def create_marker_from_filter_result(poi, result):
d.update(dict(text=result[1], hovertext=result[0])) 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. # Dict support to allow more flexible things in the future as well as polylines on the map.
elif isinstance(result, dict): elif isinstance(result, dict):
if 'text' in result:
d['text'] = result['text'] d['text'] = result['text']
# Use custom hovertext if provided... # Use custom hovertext if provided...
if 'hovertext' in result: if 'hovertext' in result:
d['hovertext'] = str(result['hovertext']) d['hovertext'] = str(result['hovertext'])
else: # ...otherwise default to display text. else: # ...otherwise default to display text.
d['hovertext'] = result['text'] d['hovertext'] = result.get('text', '')
if "icon" in result: if "icon" in result:
d["icon"] = result['icon'] d["icon"] = result['icon']

View File

@@ -404,6 +404,9 @@ overviewer.util = {
fill: db['fill'] fill: db['fill']
}; };
layerObj = db['isLine'] ? L.polyline(plLatLng, options) : L.polygon(plLatLng, options); 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) // TODO: add other config options (fill color, fill opacity)
} else { } else {
// Convert coords // Convert coords
@@ -414,7 +417,7 @@ overviewer.util = {
layerObj = new L.marker(latlng, {icon: m_icon, title: db.hovertext}); layerObj = new L.marker(latlng, {icon: m_icon, title: db.hovertext});
} }
// Add popup to marker // Add popup to marker
if (marker_entry.createInfoWindow) { if (marker_entry.createInfoWindow && db.text) {
layerObj.bindPopup(db.text); layerObj.bindPopup(db.text);
} }
// Add the polyline or marker to the layer // Add the polyline or marker to the layer