000f457fcb
* fix map height in extending example * add html and body styles to tutorial_frame * move js styles to css * remove unnecessary styles from mobile/example.md
43 lines
1.1 KiB
Markdown
43 lines
1.1 KiB
Markdown
---
|
|
layout: tutorial_frame
|
|
title: Mobile tutorial
|
|
css: "body {
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
#map {
|
|
height: 100%;
|
|
width: 100vw;
|
|
}"
|
|
---
|
|
<script>
|
|
var map = L.map('map').fitWorld();
|
|
|
|
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
|
|
maxZoom: 18,
|
|
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
|
|
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
|
|
id: 'mapbox.streets'
|
|
}).addTo(map);
|
|
|
|
function onLocationFound(e) {
|
|
var radius = e.accuracy / 2;
|
|
|
|
L.marker(e.latlng).addTo(map)
|
|
.bindPopup("You are within " + radius + " meters from this point").openPopup();
|
|
|
|
L.circle(e.latlng, radius).addTo(map);
|
|
}
|
|
|
|
function onLocationError(e) {
|
|
alert(e.message);
|
|
}
|
|
|
|
map.on('locationfound', onLocationFound);
|
|
map.on('locationerror', onLocationError);
|
|
|
|
map.locate({setView: true, maxZoom: 16});
|
|
</script>
|
|
|