标签:layer href localhost center tag copy default copyright text
<!DOCTYPE html>
<html>
<head>
<title>Leaflet debug page</title>
<link rel="stylesheet" href="../dist/leaflet.css" />
<script src="../dist/leaflet.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="screen.css" />
<link rel="stylesheet" href="../dist/MarkerCluster.css" />
<link rel="stylesheet" href="../dist/MarkerCluster.Default.css" />
<script src="../dist/leaflet.markercluster-src.js"></script>
<script type="text/javascript" src="geojson-sample.js"></script>
</head>
<body>
<div id="map"></div>
<span>Mouse over a cluster to see the bounds of its children and click a cluster to zoom to those bounds</span>
<script type="text/javascript">
var geoJsonData = {
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "id":"1", "properties": { "address": "2" }, "geometry": { "type": "Point", "coordinates": [113.2209316333,31.2210922667 ] } },
{ "type": "Feature", "id":"2", "properties": { "address": "151" }, "geometry": { "type": "Point", "coordinates": [114.2238417833,31.20975435 ] } },
{ "type": "Feature", "id":"3", "properties": { "address": "21" }, "geometry": { "type": "Point", "coordinates": [112.2169955667,31.218193 ] } },
{ "type": "Feature", "id":"4", "properties": { "address": "14" }, "geometry": { "type": "Point", "coordinates": [112.2240856667,31.2216963 ] } },
{ "type": "Feature", "id":"5", "properties": { "address": "38B" }, "geometry": { "type": "Point", "coordinates": [113.2196982333,31.2188702167 ] } },
{ "type": "Feature", "id":"6", "properties": { "address": "38" }, "geometry": { "type": "Point", "coordinates": [113.2209942 ,31.2192782833 ] } }
]
};
<!-- var mymap = L.map(‘map‘).setView([31, 113], 10); -->
var tiles = L.tileLayer(‘http://localhost/roadmap/{z}/{x}/{y}.png‘, {
maxZoom: 15,
attribution: ‘© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors‘
}),latlng = L.latLng(31, 113);
var map = L.map(‘map‘, {center: latlng, zoom: 10, layers: [tiles]});
var geojson = L.geoJson(geoJsonData, {
style: function (feature) {
return {color: feature.properties.color};
},
onEachFeature: function (feature, layer) {
var popupText = ‘geometry type: ‘ + feature.geometry.type;
if (feature.properties.address) {
popupText += ‘<br/>address: ‘ + feature.properties.address;
}
layer.bindPopup(popupText);
}
});
geojson.addLayer(new L.Marker(new L.LatLng(31.745530718801952, 113.194091796875)));
var eye1 = new L.Marker(new L.LatLng(30.7250783020332547, 111.8212890625));
var eye2 = new L.Marker(new L.LatLng(30.7360637370492077, 113.2275390625));
var nose = new L.Marker(new L.LatLng(31.3292264529974207, 112.5463867187));
var mouth = new L.Polygon([
new L.LatLng(30.3841426927920029, 111.7333984375),
new L.LatLng(30.6037944300589726, 111.964111328125),
new L.LatLng(31.6806671337507222, 112.249755859375),
new L.LatLng(31.7355743631421197, 112.67822265625),
new L.LatLng(31.5928123762763, 113.0078125),
new L.LatLng(30.3292264529974207, 113.3154296875)
]);
var markers = L.markerClusterGroup();
markers.addLayer(geojson).addLayers([eye1,eye2,nose,mouth]);
map.addLayer(markers);
</script>
</body>
</html>
标签:layer href localhost center tag copy default copyright text
原文地址:http://www.cnblogs.com/wishmo/p/2b7974e0e5fc78f9cca718d76000a2ba.html