Don't filter points of GeoJSON layer (#727)

This commit is contained in:
Norbert Renner 2023-05-17 12:27:23 +02:00
parent b772924106
commit 43b1b70a0a
3 changed files with 10 additions and 6 deletions

View file

@ -296,7 +296,7 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
},
addTrackOverlay: function (geoJSON) {
this._trackLayer = L.geoJSON(geoJSON, BR.Track.getGeoJsonOptions(layersControl)).addTo(map);
this._trackLayer = L.geoJSON(geoJSON, BR.Track.getGeoJsonOptions(layersControl, true)).addTo(map);
layersControl.addOverlay(this._trackLayer, BR.Util.sanitizeHTMLContent(this._layerName));

View file

@ -10,7 +10,7 @@ BR.tracksLoader = function (map, layersControl, routing, pois) {
options: {
// `layer` allows to use a customized version of `L.geoJson` with the same signature
layer: createGeoJsonLayer,
layerOptions: BR.Track.getGeoJsonOptions(layersControl),
layerOptions: BR.Track.getGeoJsonOptions(layersControl, true),
addToMap: false,
// File size limit in kb (default: 1024) ?
fileSizeLimit: BR.conf.trackSizeLimit || 1024 * 10,

View file

@ -5,11 +5,12 @@ BR.Track = {
/**
* Returns common options for styling and appearance of tracks
*
* @param {BR.ControlLayers} layersControl Layers control instance
* @param {BR.ControlLayers} [layersControl] Layers control instance
* @param {boolean} [filterPois=false] exclude points not of type from/via/to, set true when also calling `addPoiMarkers`
*
* @returns {Object} to pass as `options` parameter to `L.geoJson`
*/
getGeoJsonOptions: function (layersControl) {
getGeoJsonOptions: function (layersControl, filterPois = false) {
// https://github.com/mapbox/simplestyle-spec/tree/master/1.1.0
const styleMapping = [
['stroke', 'color'],
@ -34,8 +35,11 @@ BR.Track = {
},
interactive: false,
filter: function (geoJsonFeature) {
// remove POIs, added separately
return !BR.Track.isPoiPoint(geoJsonFeature);
if (filterPois) {
// remove POIs, added separately, see `addPoiMarkers`
return !BR.Track.isPoiPoint(geoJsonFeature);
}
return true;
},
pointToLayer: function (geoJsonPoint, latlng) {
// route waypoint (type=from/via/to)