Leaflet/examples/quick-start-example.html

58 lines
1.5 KiB
HTML
Raw Normal View History

2011-04-27 06:26:03 +08:00
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Quick Start Guide Example</title>
<meta charset="utf-8" />
2012-02-14 23:02:29 +08:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2011-04-27 06:26:03 +08:00
<link rel="stylesheet" href="../dist/leaflet.css" />
</head>
<body>
<div id="map" style="width: 600px; height: 400px"></div>
<script src="../dist/leaflet.js"></script>
<script>
2012-02-14 23:02:29 +08:00
2012-07-24 23:37:33 +08:00
var map = L.map('map').setView([51.505, -0.09], 13);
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-24 23:37:33 +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-24 23:37:33 +08:00
}).addTo(map);
2012-02-14 23:02:29 +08:00
2012-07-24 23:37:33 +08:00
L.marker([51.5, -0.09]).addTo(map)
.bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();
2012-02-14 23:02:29 +08:00
2012-07-24 23:37:33 +08:00
L.circle([51.508, -0.11], 500, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5
}).addTo(map).bindPopup("I am a circle.");
2012-02-14 23:02:29 +08:00
2012-07-24 23:37:33 +08:00
L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047]
]).addTo(map).bindPopup("I am a polygon.");
2012-02-14 23:02:29 +08:00
2012-07-24 23:37:33 +08:00
var popup = L.popup();
2012-02-14 23:02:29 +08:00
2012-07-24 23:37:33 +08:00
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
}
2012-02-14 23:02:29 +08:00
2011-04-27 06:26:03 +08:00
map.on('click', onMapClick);
2012-02-14 23:02:29 +08:00
2011-04-27 06:26:03 +08:00
</script>
</body>
2012-02-14 23:02:29 +08:00
</html>