2020-09-03 10:18:28 +01:00
|
|
|
<script src="{{ asset_url('javascripts/leaflet.js') }}"></script>
|
|
|
|
|
<script>
|
|
|
|
|
var polygons = []
|
|
|
|
|
|
|
|
|
|
{% for polygon in broadcast_message.simple_polygons.bleed.as_coordinate_pairs_lat_long %}
|
|
|
|
|
polygons.push(
|
|
|
|
|
L.polygon({{polygon}}, {
|
2020-09-24 15:52:38 +01:00
|
|
|
opacity: 1,
|
|
|
|
|
color: '#005ea5',
|
|
|
|
|
fillColor: '#2B8CC4',
|
2020-08-26 10:43:55 +01:00
|
|
|
fillOpacity: 0.15,
|
2020-09-24 15:52:38 +01:00
|
|
|
weight: 2,
|
|
|
|
|
dashArray: [6, 7],
|
|
|
|
|
lineCap: 'butt'
|
2020-09-03 10:18:28 +01:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
|
|
{% for polygon in broadcast_message.polygons.as_coordinate_pairs_lat_long %}
|
|
|
|
|
polygons.push(
|
|
|
|
|
L.polygon({{polygon}}, {
|
2020-09-24 15:52:38 +01:00
|
|
|
color: '#0b0b0c',
|
2020-10-02 14:15:40 +01:00
|
|
|
fillColor: '#2B8CC4',
|
2020-09-24 15:52:38 +01:00
|
|
|
fillOpacity: 0.3,
|
2020-09-03 10:18:28 +01:00
|
|
|
weight: 2
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
{% endfor %}
|
|
|
|
|
|
2020-09-03 10:55:01 +01:00
|
|
|
|
2020-10-05 13:47:21 +01:00
|
|
|
var mapElement = document.getElementById('area-list-map');
|
2020-09-03 10:55:01 +01:00
|
|
|
|
|
|
|
|
// if element is inside a details element then to make the map render correctly we open the details element
|
|
|
|
|
// and set up the map before closing the details map after
|
|
|
|
|
grandparent = mapElement.parentElement.parentElement;
|
|
|
|
|
if (grandparent.className.split(/\s+/).indexOf('govuk-details') > -1) {
|
|
|
|
|
details = grandparent;
|
|
|
|
|
details.open = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapElement.style.height = Math.max(320, window.innerHeight - mapElement.offsetTop - 100) + 'px';
|
|
|
|
|
|
|
|
|
|
var mymap = L.map(
|
2020-10-05 13:47:21 +01:00
|
|
|
'area-list-map',
|
2020-09-03 10:55:01 +01:00
|
|
|
{
|
|
|
|
|
scrollWheelZoom: false
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
|
}).addTo(mymap);
|
|
|
|
|
|
2020-09-03 10:18:28 +01:00
|
|
|
var polygonGroup = L.featureGroup(polygons).addTo(mymap);
|
|
|
|
|
mymap.fitBounds(
|
|
|
|
|
polygonGroup.getBounds(),
|
|
|
|
|
{padding: [1, 1]}
|
|
|
|
|
);
|
|
|
|
|
|
2020-09-03 10:55:01 +01:00
|
|
|
// if element is inside a details element then close the details element
|
|
|
|
|
if (details) {
|
|
|
|
|
details.open = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-03 10:18:28 +01:00
|
|
|
</script>
|