{% extends "graduated_circle.html" %} {% block graduated_circle %} // extract JSON property used for data-driven styling to add to popup {% if enableDataJoin %} {% if joinData %} let joinData = {{ joinData }}; var popUpKeys = {}, radiusPopUpKeys = {}; // 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 radiusProperty %} {% if colorProperty != radiusProperty %} radiusPopUpKeys[row["{{ dataJoinProperty }}"]] = row["{{ radiusProperty }}"]; {% endif %} {% endif %} layerFilter.push(row["{{ dataJoinProperty }}"]); }); {% endif %} {% endif %} // Add vector data source map.addSource("vector-data", { type: "vector", url: "{{ vectorUrl }}", }); // Add label layer map.addLayer({ "id": "circle-label", "source": "vector-data", "source-layer": "{{ vectorLayer }}", "type": "symbol", "maxzoom": {{ maxzoom }}, "minzoom": {{ minzoom }}, "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 }}"); // Add layer from the vector tile source with data-driven style map.addLayer({ "id": "circle", "source": "vector-data", "source-layer": "{{ vectorLayer }}", "type": "circle", "maxzoom": {{ maxzoom }}, "minzoom": {{ minzoom }}, "paint": { {% if enableDataJoin %} "circle-color": { "type": "categorical", "property": "{{ vectorJoinDataProperty }}", "stops": {{ vectorColorStops }}, "default": "{{ defaultColor }}" }, "circle-radius": { "type": "categorical", "property": "{{ vectorJoinDataProperty }}", "stops": {{ vectorRadiusStops }}, "default": {{ defaultRadius }} }, {% else %} {% if colorProperty %} "circle-color": generatePropertyExpression("{{ colorType }}", "{{ colorProperty }}", {{ colorStops }}, "{{ defaultColor }}" ), {% else %} "circle-color": "{{ defaultColor }}", {% endif %} {% if radiusProperty %} "circle-radius" : generatePropertyExpression("{{ radiusType }}", "{{ radiusProperty }}", {{ radiusStops }}, {{ defaultRadius }} ), {% else %} "circle-radius": {{ defaultRadius }}, {% endif %} {% endif %} "circle-stroke-color": "{{ strokeColor }}", "circle-stroke-width": generatePropertyExpression('interpolate', 'zoom', [[0,{{ strokeWidth }}], [18,5* {{ strokeWidth }}]]), "circle-opacity" : {{ opacity }}, "circle-stroke-opacity" : {{ opacity }} } {% if enableDataJoin %} , filter: layerFilter {% endif %} }, "circle-label"); {% endblock graduated_circle %} {% block graduated_circle_popup %} // Show the popup on mouseover map.on(popupAction, 'circle', function(e) { {% if popupOpensOnHover %} map.getCanvas().style.cursor = 'pointer'; {% endif %} let f = e.features[0]; let popup_html = '