Leaflet/docs/examples/quick-start-example.html

58 lines
1.6 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">
2016-08-03 02:14:38 +08:00
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.3/dist/leaflet.css" />
2011-04-27 06:26:03 +08:00
</head>
<body>
<div id="mapid" style="width: 600px; height: 400px"></div>
2011-04-27 06:26:03 +08:00
2016-08-03 02:14:38 +08:00
<script src="https://npmcdn.com/leaflet@1.0.0-rc.3/dist/leaflet.js"></script>
2011-04-27 06:26:03 +08:00
<script>
2012-02-14 23:02:29 +08:00
var mymap = L.map('mapid').setView([51.505, -0.09], 13);
2012-02-14 23:02:29 +08:00
2016-01-27 14:13:32 +08:00
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpandmbXliNDBjZWd2M2x6bDk3c2ZtOTkifQ._QA7i5Mpkd_m30IGElHziw', {
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'
}).addTo(mymap);
2012-02-14 23:02:29 +08:00
L.marker([51.5, -0.09]).addTo(mymap)
2012-07-24 23:37:33 +08:00
.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(mymap).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(mymap).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(mymap);
2012-07-24 23:37:33 +08:00
}
2012-02-14 23:02:29 +08:00
mymap.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>