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]-->
|
|
|
|
|
|
|
|
<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" 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 © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
|
|
|
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
|
|
|
|
|
|
|
|
var map = new L.Map('map', {
|
|
|
|
center: new L.LatLng(0.78, 102.37),
|
|
|
|
zoom: 7,
|
|
|
|
layers: [cloudmade]
|
|
|
|
});
|
|
|
|
|
|
|
|
var geojson = new L.GeoJSON();
|
|
|
|
|
2011-06-10 22:15:45 +08:00
|
|
|
/* points are rendered as markers by default, but you can change this:
|
2011-06-10 20:58:13 +08:00
|
|
|
|
|
|
|
var geojson = new L.GeoJSON(null, {
|
2011-06-10 22:15:45 +08:00
|
|
|
pointToLayer: function(latlng) { return new L.CircleMarker(latlng); }
|
2011-06-10 20:58:13 +08:00
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
2011-06-10 22:15:45 +08:00
|
|
|
|
2011-06-10 19:26:16 +08:00
|
|
|
geojson.on('featureparse', function(e) {
|
2011-06-10 20:58:13 +08:00
|
|
|
// you can style features depending on their properties, etc.
|
2011-06-12 07:11:08 +08:00
|
|
|
var popupText = 'geometry type: ' + e.geometryType + '<br/>';
|
2011-08-10 20:30:29 +08:00
|
|
|
if (e.layer.setStyle) {
|
2011-06-10 19:26:16 +08:00
|
|
|
e.layer.setStyle({color: e.properties.color});
|
2011-06-12 07:11:08 +08:00
|
|
|
popupText += 'color: ' + e.properties.color;
|
2011-06-10 19:26:16 +08:00
|
|
|
}
|
2011-06-12 07:11:08 +08:00
|
|
|
e.layer.bindPopup(popupText);
|
2011-06-10 19:26:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
geojson.addGeoJSON(geojsonSample);
|
|
|
|
|
|
|
|
map.addLayer(geojson);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|