{% extends "linestring.html" %} {% block linestring %} {% if enableDataJoin %} // extract JSON property used for data-driven styling to add to popup {% if joinData %} let joinData = {{ joinData }}; var popUpKeys = {}, lineWidthPopUpKeys = {}; // Create filter for layers from join data let layerFilter = ['in', "{{ vectorJoinDataProperty }}"] joinData.forEach(function(row, index) { {% if colorProperty %} popUpKeys[row["{{ dataJoinProperty }}"]] = row["{{ colorProperty }}"]; {% endif %} {% if widthProperty %} {% if colorProperty != widthProperty %} lineWidthPopUpKeys[row["{{ dataJoinProperty }}"]] = row["{{ widthProperty }}"]; {% endif %} {% endif %} layerFilter.push(row["{{ dataJoinProperty }}"]); }); {% endif %} {% endif %} // Add vector data source map.addSource("vector-data", { type: "vector", url: "{{ vectorUrl }}", }); // Add data layer from the vector tile source with data-driven style map.addLayer({ "id": "linestring", "source": "vector-data", "source-layer": "{{ vectorLayer }}", "type": "line", "layout": { "line-join": "round", "line-cap": "round" }, "paint": { {% if lineDashArray %} "line-dasharray": {{ lineDashArray }}, {% endif %} {% if enableDataJoin %} "line-color": { "type": "categorical", "property": "{{ vectorJoinDataProperty }}", "stops": {{ vectorColorStops }}, "default": "{{ defaultColor }}" }, "line-width": { "type": "categorical", "property": "{{ vectorJoinDataProperty }}", "stops": {{ vectorWidthStops }}, "default": {{ defaultWidth }} }, {% else %} {% if colorProperty %} "line-color": generatePropertyExpression("{{ colorType }}", "{{ colorProperty }}", {{ colorStops }}, "{{ defaultColor }}"), {% else %} "line-color": "{{ defaultColor }}", {% endif %} {% if widthProperty %} "line-width": generatePropertyExpression("{{ widthType }}", "{{ widthProperty }}", {{ widthStops }}, {{ defaultWidth }}), {% else %} "line-width": {{ defaultWidth }}, {% endif %} {% endif %} "line-opacity": {{ opacity }} } {% if enableDataJoin %} , filter: layerFilter {% endif %} }, "{{ belowLayer }}" ); // Add label layer map.addLayer({ "id": "linestring-label", "source": "vector-data", "source-layer": "{{ vectorLayer }}", "type": "symbol", "layout": { {% if labelProperty %} "text-field": "{{ labelProperty }}", {% endif %} "text-size" : generateInterpolateExpression('zoom', [[0, {{ labelSize }}],[22, 3* {{ labelSize }}]] ), "text-offset": [0,-1] }, "paint": { "text-halo-color": "{{ labelHaloColor }}", "text-halo-width": generatePropertyExpression('interpolate', 'zoom', [[0,{{ labelHaloWidth }}], [18,5* {{ labelHaloWidth }}]]), "text-color": "{{ labelColor }}" } {% if enableDataJoin %} , filter: layerFilter {% endif %} }, "{{belowLayer}}" ); {% endblock linestring %} {% block linestring_popup %} // Show the popup on mouseover map.on(popupAction, 'linestring', function(e) { {% if popupOpensOnHover %} map.getCanvas().style.cursor = 'pointer'; {% endif %} let f = e.features[0]; let popup_html = '