{% extends "base.html" %} {% block legend %} {% if colorStops and colorProperty and radiusProperty %} calcCircleColorLegend({{ colorStops }}, "{{ colorProperty }} vs. {{ radiusProperty }}"); {% else %} document.getElementById('legend').style.visibility='hidden' {% endif %} {% endblock legend %} {% block map %} map.on('style.load', function() { map.addSource("data", { "type": "geojson", "data": {{ geojson_data }}, //data from dataframe output to geojson "buffer": 0, "maxzoom": 14 }); map.addLayer({ "id": "label", "source": "data", "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 }}" } }, "{{belowLayer}}" ) map.addLayer({ "id": "circle", "source": "data", "type": "circle", "maxzoom": {{ maxzoom }}, "minzoom": {{ minzoom }}, "paint": { {% 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 %} "circle-stroke-color": "{{ strokeColor }}", "circle-stroke-width": generatePropertyExpression('interpolate', 'zoom', [[0,{{ strokeWidth }}], [18,5* {{ strokeWidth }}]]), "circle-opacity" : {{ opacity }}, "circle-stroke-opacity" : {{ opacity }} } }, "label"); // Create a popup var popup = new mapboxgl.Popup({ closeButton: false, closeOnClick: false }); // Show the popup on mouseover map.on('mousemove', 'circle', function(e) { map.getCanvas().style.cursor = 'pointer'; let f = e.features[0]; let popup_html = '