Leaflet/debug/vector/geojson.html

52 lines
1.5 KiB
HTML
Raw Normal View History

2011-06-10 19:26:16 +08:00
<!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]-->
2011-12-15 18:20:09 +08:00
2011-06-10 19:26:16 +08:00
<link rel="stylesheet" href="../css/screen.css" />
2011-12-15 18:20:09 +08:00
2011-06-10 19:26:16 +08:00
<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" src="geojson-sample.js"></script>
<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});
2011-12-15 18:20:09 +08:00
2011-06-10 19:26:16 +08:00
var map = new L.Map('map', {
2011-12-15 18:21:42 +08:00
center: new L.LatLng(0.78, 102.37),
zoom: 7,
2011-06-10 19:26:16 +08:00
layers: [cloudmade]
});
2011-12-15 18:20:09 +08:00
var geojson = L.geoJson(geojsonSample, {
style: function (feature) {
return {color: feature.properties.color};
},
2011-12-15 18:20:09 +08:00
onEachFeature: function (feature, layer) {
var popupText = 'geometry type: ' + feature.geometry.type;
2011-12-15 18:20:09 +08:00
if (feature.properties.color) {
popupText += '<br/>color: ' + feature.properties.color
}
layer.bindPopup(popupText);
2011-06-10 19:26:16 +08:00
}
});
2011-12-15 18:20:09 +08:00
2011-06-10 19:26:16 +08:00
map.addLayer(geojson);
</script>
</body>
2011-12-15 18:20:09 +08:00
</html>