-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
53 lines (46 loc) · 1.36 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<div id="mapid" style= "width:800px; height: 600px;"></div>
<script>
window.onload = function() {
var basemap = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});
$.getJSON("map.geojson", function(data) {
var geojson = L.geoJson(data, {
style: function(feature){
var mtype = feature.properties.name;
if (mtype === "median") {
return {
color: "red"
};
} else {
return {
color: "blue"
};
}
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.name);
},
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, {
radius: 10,
});
},
});
var map = L.map('mapid')
.fitBounds(geojson.getBounds());
basemap.addTo(map);
geojson.addTo(map);
});
};
</script>
</html>