More robust leaflet scritping.
This commit is contained in:
parent
ae5cb673ab
commit
ae40d3bf8e
@ -9,10 +9,12 @@
|
||||
|
||||
@if let Some(ref pos) = position {
|
||||
<div id="map"></div>
|
||||
<link href="https://rasmus.krats.se/static/leaflet077c/leaflet.css" rel="stylesheet"/>
|
||||
<script language="javascript" src="https://rasmus.krats.se/static/leaflet077c/leaflet.js" type="text/javascript">
|
||||
</script>
|
||||
<script language="javascript" type="text/javascript">
|
||||
fn initMap() @{
|
||||
var csslink = document.createElement('link');
|
||||
csslink.rel = 'stylesheet';
|
||||
csslink.href = 'https://rasmus.krats.se/static/leaflet077c/leaflet.css';
|
||||
document.getElementById('head').append(csslink);
|
||||
var pos = [@pos.x, @pos.y];
|
||||
var map = document.getElementById('map');
|
||||
map.style.height = 3 * map.clientWidth / 4 + "px";
|
||||
@ -21,6 +23,9 @@
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
@}).addTo(map);
|
||||
L.marker(pos).addTo(map);
|
||||
@}
|
||||
</script>
|
||||
<script language="javascript" src="https://rasmus.krats.se/static/leaflet077c/leaflet.js" type="text/javascript" async onload="initmap">
|
||||
</script>
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user