Leaflet/debug/map/map.html

76 lines
2.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Leaflet debug page</title>
<link rel="stylesheet" href="../../dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
<link rel="stylesheet" href="../css/screen.css" />
<script src="../leaflet-include.js"></script>
</head>
<body>
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
<button id="populate">Populate with 10 markers</button>
<script type="text/javascript">
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
latlng = new L.LatLng(50.5, 30.51);
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
var markers = new L.FeatureGroup();
function populate() {
var bounds = map.getBounds(),
southWest = bounds.getSouthWest(),
northEast = bounds.getNorthEast(),
lngSpan = northEast.lng - southWest.lng,
latSpan = northEast.lat - southWest.lat;
for (var i = 0; i < 10; i++) {
var latlng = new L.LatLng(
southWest.lat + latSpan * Math.random(),
southWest.lng + lngSpan * Math.random());
markers.addLayer(new L.Marker(latlng));
}
return false;
};
markers.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.</p>");
map.addLayer(markers);
populate();
L.DomUtil.get('populate').onclick = populate;
var ng1 = new L.LatLng(13.403, 5.361),
ng2 = new L.LatLng(13.623, 14.370),
ng3 = new L.LatLng(11.338, 15.469),
ng4 = new L.LatLng(11.118, 14.722),
ng5 = new L.LatLng(6.328, 12.129),
ng6 = new L.LatLng(7.031, 11.250),
ng7 = new L.LatLng(5.625, 9.888),
ng8 = new L.LatLng(4.570, 9.536),
ng9 = new L.LatLng(4.219, 7.075),
ng10 = new L.LatLng(6.152, 5.625),
ng11 = new L.LatLng(6.372, 3.604),
ng12 = new L.LatLng(8.965, 3.647),
ng13 = new L.LatLng(10.283, 4.878),
ng14 = new L.LatLng(11.470, 4.482),
ng15 = new L.LatLng(13.447, 5.142),
polygonPoints = [ng1, ng2, ng3, ng4, ng5, ng6, ng7, ng8, ng9, ng10, ng11, ng12, ng13, ng14, ng15];
var polygonNG = new L.Polygon(polygonPoints, {stroke: false, fillOpacity: 0.5});
map.addLayer(polygonNG);
</script>
</body>
</html>