-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
200 lines (168 loc) · 5.56 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html>
<head>
<title>Map Example</title>
<meta charset="utf-8"/>
<!-- we will use this as the styling script for our webmap-->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css"/>
<style>
#map {
width: 850px;
height: 500px;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.info h4 {
margin: 0 0 5px;
color: #777;
}
.legend {
text-align: left;
line-height: 18px;
color: #555;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
</style>
</head>
<body>
<div id="map" style="align: center;width: 900px; height: 600px"></div>
<!-- this is the initial look of the map. in most cases it is done externally using something like a map.css stylesheet were you can specify the look of map elements, like background color tables and so on.-->
<!-- this is the javascript file that does the magic-->
<script src="C:\LeafletJS\leaflet.js""></script>
<!-- This is where our datafiles go -->
<script src="C:\Users\acano\MappingTest\maryland.js"></script>
<!-- NB: Dropping the "." in raw.github.com allows this to work in Chrome (which enforces a strict MIME type) -->
<script src="https://rawgithub.com/AnnieGitUrGun/MappingTest/master/baltimoreCounty.js"></script>
<!-- <script src="https://rawgithub.com/AnnieGitUrGun/MappingTest/master/AnnesPOI.js"></script>-->
<script src="https://rawgithub.com/AnnieGitUrGun/MappingTest/master/maryland.js"></script>
<script src="SelectVisByCounty.json"></script>
<script>
// The URL for the map which includes our CloudMade API key.
var cmAttr = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
myMapURL = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/{styleId}/256/{z}/{x}/{y}.png';
var minimal = L.tileLayer(myMapURL, {
styleId: 22677,
attribution: cmAttr
}),
midnight = L.tileLayer(myMapURL, {
styleId: 999,
attribution: cmAttr
});
// This is a mapnik basemap
var anne = L.tileLayer('http://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png');
</script>
<script>
// Styles our county layer
// var countyStyle = {
// "color": "#ff7c00",
// "weight": 3,
// "opacity": 0.25
// };
// Create our County layer
// var county = new L.geoJson(baltimoreCounty, {
// //some options
// style: countyStyle
// });
// Style our Maryland layer
// var mdStyle = {
// "weight": 3,
// "opacity": 0.25,
// "color": "#ff7c00",
// "dashArray": 4
// };
// Create the Maryland layer
var maryland = new L.geoJson(maryland, {
style: style,
onEachFeature: onEachFeature
});
// Create our POI layer and add popups
// var poi = new L.geoJson(annesPOI, {
// // add options...eventually
// onEachFeature: function (feature, layer) {
// layer.bindPopup('<b>' + feature.properties.Name + ": " + '</b>' + feature.properties.Comments);
// }
// });
// Create our map object, center it, set initial zoom level, and list all of the layers
var map = L.map('map', {
center: new L.LatLng(38.999, -77.200),
zoom: 8,
layers: [minimal, maryland]
});
// Adding our basemaps to baseLayers
var baseLayers = {
"Minimal": minimal,
//"Night View": midnight,
//"Anne": anne
};
// Adding our vectors
var overlays = {
//"County": county,
"Maryland": maryland,
//"POI": poi
};
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 5,
color: '#D40808',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
info.update(layer.feature.properties);
}
function style(feature) {
return {
"weight": 3,
"opacity": 0.25,
"color": "#ff7c00",
"dashArray": 4
//fillColor: getColor(feature)
};
}
function resetHighlight(e) {
maryland.resetStyle(e.target);
info.update();
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: zoomToFeature,
});
}
// Simple working popup example
//poi.bindPopup("I am a marker!");
// Add our baselayers and overlays to the map
L.control.layers(baseLayers, overlays).addTo(map);
// Add the control that shows county info on hover
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (props) {
this._div.innerHTML = '<h4>Visitors by County</h4>' + (props ? '<b>' + props.COUNTYNAME + ':</b> ' + props.NUMVIS + '<br />' : 'Hover over a county');
};
info.addTo(map);
</script>
</body>
</html>