86 lines
2.8 KiB
HTML
86 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Leaflet GeoJSON example</title>
|
|
|
|
<link rel="stylesheet" href="../dist/leaflet.css" />
|
|
<!--[if lte IE 8]><link rel="stylesheet" href="../dist/leaflet.ie.css" /><![endif]-->
|
|
|
|
<script src="../dist/leaflet.js"></script>
|
|
<!--<script src="../debug/leaflet-include.js"></script>-->
|
|
<script src="sample-geojson.js" type="text/javascript"></script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width: 600px; height: 400px"></div>
|
|
|
|
<script>
|
|
var map = new L.Map('map');
|
|
|
|
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/22677/256/{z}/{x}/{y}.png',
|
|
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
|
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
|
|
|
|
map.setView(new L.LatLng(39.74738794765598, -105.00002861022949), 14)
|
|
.addLayer(cloudmade);
|
|
|
|
var BaseballIcon = L.Icon.extend({
|
|
iconUrl: 'baseball-marker.png',
|
|
shadowUrl: null,
|
|
iconSize: new L.Point(32, 37),
|
|
shadowSize: null,
|
|
iconAnchor: new L.Point(14, 37),
|
|
popupAnchor: new L.Point(2, -32)
|
|
});
|
|
|
|
var geojson_layer = new L.GeoJSON( null, {
|
|
pointToLayer: function ( latlng ) {
|
|
return new L.CircleMarker( latlng, {
|
|
radius: 8,
|
|
fillColor: "#ff7800",
|
|
color: "#000",
|
|
weight: 1,
|
|
opacity: 1,
|
|
fillOpacity: 0.8
|
|
} );
|
|
|
|
}
|
|
} );
|
|
|
|
var another_geojson_layer = new L.GeoJSON( coors_field, {
|
|
pointToLayer: function ( latlng ) {
|
|
return new L.Marker( latlng, {
|
|
icon: new BaseballIcon()
|
|
} );
|
|
}
|
|
} );
|
|
|
|
geojson_layer.on( "featureparse", function( e ) {
|
|
var popup_content = "<p>I started out as a GeoJSON " + e.geometryType + ", but now I'm a Leaflet vector!</p>";
|
|
if ( e.properties && e.properties.popup_content ) {
|
|
popup_content += e.properties.popup_content;
|
|
}
|
|
e.layer.bindPopup( popup_content );
|
|
if ( e.properties && e.properties.style ) {
|
|
e.layer.setStyle( e.properties.style );
|
|
}
|
|
} );
|
|
|
|
another_geojson_layer.on( "featureparse", function ( e ) {
|
|
var popup_content = "<p>I started out as a GeoJSON " + e.geometryType + ", but now I'm a Leaflet vector!</p>";
|
|
if ( e.properties && e.properties.popup_content ) {
|
|
popup_content += e.properties.popup_content;
|
|
}
|
|
e.layer.bindPopup( popup_content );
|
|
} );
|
|
|
|
map.addLayer( geojson_layer ).addLayer( another_geojson_layer );
|
|
|
|
geojson_layer.addGeoJSON( free_bus );
|
|
geojson_layer.addGeoJSON( bicycle_rental );
|
|
geojson_layer.addGeoJSON( campus );
|
|
|
|
another_geojson_layer.addGeoJSON( coors_field );
|
|
|
|
</script>
|
|
</body>
|
|
</html> |