57 lines
1.4 KiB
HTML
57 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Leaflet mobile example</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
|
|
<link rel="stylesheet" href="../dist/leaflet.css" />
|
|
<!--[if lte IE 8]><link rel="stylesheet" href="../dist/leaflet.ie.css" /><![endif]-->
|
|
|
|
<script src="../dist/leaflet.js"></script>
|
|
|
|
<style>
|
|
body {
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
html, body, #map {
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="map"></div>
|
|
|
|
<script>
|
|
var map = new L.Map('map');
|
|
|
|
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
|
|
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
|
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
|
|
|
|
map.addLayer(cloudmade);
|
|
|
|
map.on('locationfound', onLocationFound);
|
|
map.on('locationerror', onLocationError);
|
|
|
|
map.locateAndSetView();
|
|
|
|
function onLocationFound(e) {
|
|
var radius = e.accuracy / 2;
|
|
|
|
var marker = new L.Marker(e.latlng);
|
|
map.addLayer(marker);
|
|
marker.bindPopup("You are within " + radius + " meters from this point").openPopup();
|
|
|
|
var circle = new L.Circle(e.latlng, radius);
|
|
map.addLayer(circle);
|
|
}
|
|
|
|
function onLocationError(e) {
|
|
alert(e.message);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|