Skip to content

Commit

Permalink
Fix map
Browse files Browse the repository at this point in the history
  • Loading branch information
portableant committed Jul 23, 2023
1 parent 969a4cc commit 8c9d48c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
4 changes: 1 addition & 3 deletions _includes/structure/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
<!-- Cookie management -->
<script defer type="text/javascript" src="{{site.baseurl}}/js/config.js"></script>
<script defer type="text/javascript" src="{{site.baseurl}}/js/klaro.js"></script>
<!-- End of body -->

<script>
<!-- End of body -->
52 changes: 27 additions & 25 deletions _includes/structure/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,36 @@

<script type="text/javascript">

var dareLayer = L.tileLayer('https://dh.gu.se/tiles/imperium/{z}/{x}/{y}.png', {
attribution: 'Tiles: <a href="http://imperium.ahlfeldt.se/">DARE 2014</a>'
}),
var dareLayer = L.tileLayer('https://dh.gu.se/tiles/imperium/{z}/{x}/{y}.png', {
attribution: 'Tiles: <a href="http://imperium.ahlfeldt.se/">DARE 2014</a>'
}),

awmcLayer = L.tileLayer('https://dh.gu.se/tiles/imperium/{z}/{x}/{y}.png', {
attribution: 'Recogito/Pelagios Tiles &copy; <a href="http://mapbox.com/" target="_blank">MapBox</a> | ' +
'Data &copy; <a href="https://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> and contributors, CC-BY-SA | '+
awmcLayer = L.tileLayer('https://dh.gu.se/tiles/imperium/{z}/{x}/{y}.png', {
attribution: 'Recogito/Pelagios Tiles &copy; <a href="http://mapbox.com/" target="_blank">MapBox</a> | ' +
'Data &copy; <a href="https://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> and contributors, CC-BY-SA | ' +
'Tiles and Data &copy; 2013 <a href="http://www.awmc.unc.edu" target="_blank">AWMC</a> ' +
'<a href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US" target="_blank">CC-BY-NC 3.0</a>'
});

var map = new L.Map('map', {
center: new L.LatLng(34.82,24.14 ),
zoom: 5,
layers: [awmcLayer],
minZoom: 5,
maxZoom: 11
});
{% for json in page.geoJson %}
// load GeoJSON from an external file
$.getJSON("{{site.baseurl}}{{json.file}}",function(data){
// add GeoJSON layer to the map once the file is loaded
L.geoJson(data, {
onEachFeature: function (feature, layer) {
layer.bindPopup('<h3 class="lead text-info">'+feature.properties.titles+'</h3>');
}
}).addTo(map);
});
{% endfor %}

var map = new L.Map('map', {
center: new L.LatLng(34.82, 24.14),
zoom: 5,
layers: [awmcLayer],
minZoom: 5,
maxZoom: 11
});
{%
for json in page.geoJson %}

const xhr = new XMLHttpRequest();
xhr.open('GET', '{{site.baseurl}}{{json.file}}');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.responseType = 'json';
xhr.onload = function () {
if (xhr.status !== 200) return
L.geoJSON(xhr.response).addTo(map);
};
xhr.send();
{% endfor %}
</script>
{% endif %}
3 changes: 1 addition & 2 deletions map.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ layout: funders
geoJson:
-
file: /geojson/places.json
-
file: /geojson/secondary.json

---
<div id="map" style="width: 100%; height: 600px;"></div>

0 comments on commit 8c9d48c

Please sign in to comment.