aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/debug/geojson/geojson.html
blob: 319e7c13b1497424f2cdeb94c3f605537a043478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!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 &copy; 2011 OpenStreetMap contributors, Imagery &copy; 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();
		
		/* points are rendered as markers by default, but you can change this:
			
		var geojson = new L.GeoJSON(null, {
			pointToLayer: function(latlng) { return new L.CircleMarker(latlng); }
		});
		*/
		
		
		geojson.on('featureparse', function(e) {
			// you can style features depending on their properties, etc.
			var popupText = 'geometry type: ' + e.geometryType + '<br/>';
			if (e.layer instanceof L.Path) {
				e.layer.setStyle({color: e.properties.color});
				popupText += 'color: ' + e.properties.color;
			}
			e.layer.bindPopup(popupText);
		});
		
		geojson.addGeoJSON(geojsonSample);
		
		map.addLayer(geojson);
	</script>
</body>
</html>