Leaflet/examples/mobile-example.html

56 lines
1.5 KiB
HTML
Raw Normal View History

2011-04-27 22:11:24 +08:00
<!DOCTYPE html>
<html>
<head>
<title>Leaflet mobile example</title>
2012-02-14 23:02:29 +08:00
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
2015-10-26 18:16:47 +08:00
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
2012-02-14 23:02:29 +08:00
2015-10-26 18:16:47 +08:00
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
2011-04-27 22:11:24 +08:00
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
2012-02-14 23:02:29 +08:00
</style>
2011-04-27 22:11:24 +08:00
</head>
<body>
<div id="map"></div>
<script>
2012-07-25 23:51:38 +08:00
var map = L.map('map');
2012-02-14 23:02:29 +08:00
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6IjZjNmRjNzk3ZmE2MTcwOTEwMGY0MzU3YjUzOWFmNWZhIn0.Y8bhBaUMqFiPrDRW9hieoQ', {
2012-07-25 23:51:38 +08:00
maxZoom: 18,
2014-04-28 19:16:15 +08:00
attribution: 'Map data &copy; <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'
2012-07-25 23:51:38 +08:00
}).addTo(map);
2012-02-14 23:02:29 +08:00
2011-04-28 05:11:52 +08:00
function onLocationFound(e) {
2011-05-19 22:29:37 +08:00
var radius = e.accuracy / 2;
2012-07-25 23:51:38 +08:00
L.marker(e.latlng).addTo(map)
.bindPopup("You are within " + radius + " meters from this point").openPopup();
2012-02-14 23:02:29 +08:00
2012-07-25 23:51:38 +08:00
L.circle(e.latlng, radius).addTo(map);
2011-04-28 05:11:52 +08:00
}
2012-02-14 23:02:29 +08:00
2011-04-28 05:11:52 +08:00
function onLocationError(e) {
2011-05-19 22:29:37 +08:00
alert(e.message);
2011-04-28 05:11:52 +08:00
}
2012-07-25 23:51:38 +08:00
map.on('locationfound', onLocationFound);
map.on('locationerror', onLocationError);
map.locate({setView: true, maxZoom: 16});
2011-04-27 22:11:24 +08:00
</script>
</body>
2012-02-14 23:02:29 +08:00
</html>