This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
243 lines (206 loc) · 6.84 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<html>
<head>
<meta charset="UTF-8">
<title>OpenStreetMap Philippines Imagery Coverage Map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js"></script>
<script src="Bing.js"></script>
<script src="bingkey.js"></script>
<script type="text/javascript">
var XhrObject = new XMLHttpRequest();
var Map;
var LayersControl;
window.onload = function() {
// Specify default map location
var initLat = 12.5;
var initLng = 122;
var initZoom = 6;
// Obtain map location from URL fragment (permalink) if any
if (location.hash) {
var coords = location.hash.split(',');
initLat = Number(coords[0].substr(1));
initLng = Number(coords[1]);
initZoom = Number(coords[2]);
}
// Initialize the map and permalink
Map = new L.Map('map', {
center : new L.LatLng(initLat, initLng),
zoom : initZoom
});
updatePermalink();
// Declare tile layer control data object
var tilesLayers = new Object;
// Create the OSM Mapnik tile layer
var osmURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmLayer = new L.TileLayer(osmURL, {
attribution : 'Tiles © OpenStreetMap (CC-BY-SA 2.0)',
});
tilesLayers["OSM Default"] = osmLayer;
// Create the MapQuest tile layer
var mapquestURL = 'http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
var mapquestLayer = new L.TileLayer(mapquestURL, {
subdomains : ['otile1', 'otile2', 'otile3', 'otile4'],
attribution : 'Tiles © <a href="http://open.mapquest.com/">MapQuest</a>',
});
tilesLayers["MapQuest"] = mapquestLayer;
// Create the Stamen Toner tile layer
var stamenTonerURL = 'http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png';
var stamenTonerLayer = new L.TileLayer(stamenTonerURL, {
attribution : 'Tiles © <a href="http://maps.stamen.com/#toner">Stamen</a> (CC-BY 3.0)',
});
tilesLayers["Stamen Toner"] = stamenTonerLayer;
// Create the Bing Maps Aerial tile layers
if (typeof bingKey != 'undefined') {
var bingLayer = new L.BingLayer(bingKey, {type: 'Aerial' });
var bingLabeledLayer = new L.BingLayer(bingKey, {type: 'AerialWithLabels'});
tilesLayers["Bing Aerial" ] = bingLayer;
tilesLayers["Bing Aerial (labeled)"] = bingLabeledLayer;
};
// Add the MapQuest tile layer to the map (default)
Map.addLayer(mapquestLayer);
// Add layer control to map (base layers first)
LayersControl = new L.Control.Layers(tilesLayers);
Map.addControl(LayersControl);
// Add event handlers to update the permalink target
Map.on('zoomend', updatePermalink);
Map.on('moveend', updatePermalink);
// Add event handlers for the edit buttons
document.getElementById('editpotlatch').onclick = editInPotlatch;
document.getElementById('editjosm' ).onclick = editInJosm;
// Load the imagery coverage data
XhrObject.onreadystatechange = processOutlines;
XhrObject.open('GET', 'data.geojson', true);
XhrObject.overrideMimeType('text/plain');
XhrObject.send(null);
}
function processOutlines() {
if (XhrObject.readyState != 4) return;
// Load the imagery coverage data
var data = JSON.parse(XhrObject.responseText);
// Process the imagery coverage data (each outline group)
for (i = 0; i < data.features.length; i++) {
var feature = data.features[i];
var outlinesLayer = L.geoJson(feature, {
style: function(feature) {
return {
stroke : true,
color : feature.properties.color,
opacity : 0.6,
weight : 1,
fill : true,
fillColor : feature.properties.color,
fillOpacity : 0.3,
clickable : false,
};
}
});
// Bing is shown by default
if (feature.id.match(/^Bing/)) {
Map.addLayer(outlinesLayer);
}
// Add the processed outline group to the layer control
LayersControl.addOverlay(outlinesLayer, feature.id);
}
}
function updatePermalink() {
var latLng = Map.getCenter();
var lat = latLng.lat;
var lng = latLng.lng;
var zoom = Map.getZoom();
lat = Math.floor(lat * 1000000) / 1000000;
lng = Math.floor(lng * 1000000) / 1000000;
document.getElementById('permalink').href = '#' + lat + ',' + lng + ',' + zoom;
document.getElementById('osmlink').href = 'http://osm.org/?lat=' + lat + '&lon=' + lng + '&zoom=' + zoom;
}
function editInPotlatch() {
if (Map.getZoom() > 13) {
var latLng = Map.getCenter();
var lat = latLng.lat;
var lng = latLng.lng;
var zoom = Map.getZoom();
var url = 'http://osm.org/edit?lat=' + lat + '&lon=' + lng + '&zoom=' + zoom;
window.open(url, 'popup');
}
else {
alert('Please zoom in some more.');
}
}
function editInJosm() {
var bounds = Map.getBounds();
var minLat = bounds.getSouthWest().lat;
var maxLat = bounds.getNorthEast().lat;
var minLng = bounds.getSouthWest().lng;
var maxLng = bounds.getNorthEast().lng;
// There is an API limit of 0.25 square degrees
if (((maxLat - minLat) * (maxLng - minLng)) < 0.25) {
var url = 'http://127.0.0.1:8111/load_and_zoom?left='
+ minLng + '&right=' + maxLng + '&top=' + maxLat + '&bottom=' + minLat;
window.open(url, 'popup');
}
else {
alert('Please zoom in some more.');
}
};
</script>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
#infopane {
float: left;
width: 200px;
height: 100%;
overflow: auto;
background: #ccc;
font-size: 11px;
color: #444;
}
h1 {
margin: 0;
padding: 10px;
font-size: 14px;
background: #888;
color: white;
}
p {
margin: 10px;
}
a {
color: #48F;
}
#credits {
border-top: 1px solid #AAA;
padding-top: 5px;
font-size: 9px;
color: #888;
}
#credits a {
color: #8AF;
}
#map {
margin-left: 150px;
height: 100%;
}
</style>
</head>
<body>
<div id="infopane">
<h1>OSMPH Imagery Coverage Map</h1>
<p>This is a map that shows the coverage of satellite/aerial imagery in the
Philippines that is available for tracing by OpenStreetMap contributors.
<a href="http://wiki.openstreetmap.org/wiki/Philippines/High-resolution_imagery">More information</a>.</p>
<ul>
<li><a id="permalink" href="#">Permalink</a></li>
<li><a id="osmlink" href="#">Link to OSM</a></li>
<li><a id="editpotlatch" href="#">Edit in Potlatch</a></li>
<li><a id="editjosm" href="#">Edit in JOSM</a></li>
</ul>
<p id="credits">Map data © OpenStreetMap contributors (<a href="http://www.openstreetmap.org/copyright">terms</a>). <a href="https://github.com/OSMPH/Imagery_Coverage_Map">Fork this website on Github</a>.</p>
</div>
<div id="map"></div>
</body>
</html>