2016-09-30 19:56:05 +08:00
|
|
|
---
|
|
|
|
layout: tutorial_frame
|
|
|
|
title: Mobile tutorial
|
|
|
|
css: "body {
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
html, body, #map {
|
2017-09-10 13:36:01 +08:00
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
2016-09-30 19:56:05 +08:00
|
|
|
}"
|
|
|
|
---
|
|
|
|
<script>
|
|
|
|
var map = L.map('map').fitWorld();
|
|
|
|
|
2017-02-16 15:44:50 +08:00
|
|
|
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
|
2016-09-30 19:56:05 +08:00
|
|
|
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>
|
|
|
|
|