Skip to content

Commit e03c730

Browse files
committed
change mapping provider
1 parent 67db2ac commit e03c730

2 files changed

Lines changed: 34 additions & 12 deletions

File tree

findthatpostcode/templates/merge-geojson.html.j2

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,24 @@
6262
files</button>
6363
</div>
6464
<div class="w-100 w-60-l pl3 fl">
65-
<l-map v-if="result.features.length" style="height: 500px; width: 100%" :bounds="bounds">
65+
<l-map ref="resultMap" style="height: 500px; width: 100%" :bounds="bounds"
66+
:style="{ opacity: result.features.length ? 1 : 0 }">
6667
<l-geo-json :geojson="result"></l-geo-json>
67-
<l-tile-layer url="https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.png"
68-
:attribution="attribution" />
6968
</l-map>
7069
</div>
7170
</div>
7271
{% endblock %}
7372

7473
{% block headscripts %}
7574
<link rel="stylesheet" href="{{ url_for('static', filename='lib/leaflet/leaflet.css' )}}" />
75+
<link rel="stylesheet" href="{{ url_for('static', filename='lib/maplibre/maplibre-gl.css' )}}" />
7676
{% endblock %}
7777

7878
{% block bodyscripts %}
7979
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
8080
<script src="{{ url_for('static', filename='lib/leaflet/leaflet.js' )}}"></script>
81+
<script src="{{ url_for('static', filename='lib/maplibre/maplibre-gl.js' )}}"></script>
82+
<script type="text/javascript" src="{{ url_for('static', filename='lib/maplibre/leaflet-maplibre-gl.js') }}"></script>
8183
<script src="//unpkg.com/vue2-leaflet"></script>
8284
<script>
8385
Vue.component('l-map', window.Vue2Leaflet.LMap);
@@ -95,8 +97,6 @@
9597
filename: 'mergedfile',
9698
enableTooltip: true,
9799
bounds: [[-90, -180], [90, 180]],
98-
attribution:
99-
'&copy; <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a> <a href="https://www.stamen.com/" target="_blank">&copy; Stamen Design</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/about" target="_blank">OpenStreetMap</a> contributors',
100100
},
101101
watch: {
102102
'files': function () {
@@ -144,7 +144,18 @@
144144
clearFiles() {
145145
this.files = [];
146146
},
147-
}
147+
},
148+
mounted() {
149+
this.$nextTick(() => {
150+
L.maplibreGL({
151+
style: 'https://tiles.openfreemap.org/styles/positron',
152+
attribution: `
153+
<a href="https://openfreemap.org" target="_blank">OpenFreeMap</a>
154+
<a href="https://www.openmaptiles.org/" target="_blank">&copy; OpenMapTiles</a>
155+
Data from <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>`,
156+
}).addTo(this.$refs.resultMap.mapObject);
157+
});
158+
},
148159
});
149160
</script>
150161
{% endblock %}

findthatpostcode/templates/reduce-geojson.html.j2

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,24 @@
6464
</template>
6565
</div>
6666
<div class="w-100 w-60-l pl3 fl">
67-
<l-map v-if="result.features.length" style="height: 500px; width: 100%" :bounds="bounds">
67+
<l-map ref="resultMap" style="height: 500px; width: 100%" :bounds="bounds"
68+
:style="{ opacity: result.features.length ? 1 : 0 }">
6869
<l-geo-json :geojson="result"></l-geo-json>
69-
<l-tile-layer url="https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.png"
70-
:attribution="attribution" />
7170
</l-map>
7271
</div>
7372
</div>
7473
{% endblock %}
7574

7675
{% block headscripts %}
7776
<link rel="stylesheet" href="{{ url_for('static', filename='lib/leaflet/leaflet.css' )}}" />
77+
<link rel="stylesheet" href="{{ url_for('static', filename='lib/maplibre/maplibre-gl.css' )}}" />
7878
{% endblock %}
7979

8080
{% block bodyscripts %}
8181
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
8282
<script src="{{ url_for('static', filename='lib/leaflet/leaflet.js' )}}"></script>
83+
<script src="{{ url_for('static', filename='lib/maplibre/maplibre-gl.js' )}}"></script>
84+
<script type="text/javascript" src="{{ url_for('static', filename='lib/maplibre/leaflet-maplibre-gl.js') }}"></script>
8385
<script src="//unpkg.com/vue2-leaflet"></script>
8486
<script>
8587
// recursively round all coordinates in a javascript array
@@ -110,8 +112,6 @@
110112
filename: 'mergedfile',
111113
enableTooltip: true,
112114
bounds: [[-90, -180], [90, 180]],
113-
attribution:
114-
'&copy; <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a> <a href="https://www.stamen.com/" target="_blank">&copy; Stamen Design</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/about" target="_blank">OpenStreetMap</a> contributors',
115115
},
116116
watch: {
117117
'file': function () {
@@ -201,7 +201,18 @@
201201
link.click();
202202
URL.revokeObjectURL(link.href);
203203
},
204-
}
204+
},
205+
mounted() {
206+
this.$nextTick(() => {
207+
L.maplibreGL({
208+
style: 'https://tiles.openfreemap.org/styles/positron',
209+
attribution: `
210+
<a href="https://openfreemap.org" target="_blank">OpenFreeMap</a>
211+
<a href="https://www.openmaptiles.org/" target="_blank">&copy; OpenMapTiles</a>
212+
Data from <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>`,
213+
}).addTo(this.$refs.resultMap.mapObject);
214+
});
215+
},
205216
});
206217
</script>
207218
{% endblock %}

0 commit comments

Comments
 (0)