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
|
|
|
|
2012-07-24 23:37:33 +08:00
|
|
|
L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
|
|
|
|
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://cloudmade.com">CloudMade</a>'
|
|
|
|
}).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>
|