-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
383 lines (344 loc) · 14.5 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<!-- many links at https://josm.openstreetmap.de/wiki/Maps -->
<!doctype html>
<html lang="en">
<head>
<!-- Link to the stylesheet(s) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.1.0/ol.css" type="text/css"><!-- if I put the local library here this does not work well-->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/src/ol-layerswitcher.css" type="text/css">
<!-- Dimension of the map on the webpage -->
<style>
.map {
height: 600px;
width: 100%;
}
</style>
<!-- Link to the OpenLayers library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.1.0/ol.js" type="text/javascript"></script><!-- if I put the local library here this does not work well-->
<!-- Link to the layerswitcher library as not yet (as of 2015-02-03) implemented in OpenLayers3 -->
<script src="https://unpkg.com/[email protected]" type="text/javascript"></script>
<title>OpenLayers 3 example</title>
</head>
<body>
<!-- Title of the page -->
<h2>Examples of global WMS base maps</h2>
<!-- div called "map" that will be the target of the variable "map" -->
<div id="map" class="map"></div>
<div id="projMouse"></div>
<!-- Script containing all the necessary elements to display the map -->
<script type="text/javascript">
//=======================================================================================================================================
// Base layers
//=======================================================================================================================================
// WMS BlueMarble new
var BlueMarble = new ol.layer.Tile({
type:'base',
visible:true,
title: "BlueMarble",
source: new ol.source.TileWMS({
url: 'http://neowms.sci.gsfc.nasa.gov/wms/wms?',
//url: 'https://demo.boundlessgeo.com/geoserver/ows?',
params: {LAYERS: 'BlueMarbleNG', TILED: true},
//params: {LAYERS: 'nasa:bluemarble', TILED: true},
attributions: [new ol.Attribution({ html: ['Data © NASA Blue Marble'] })]
})
}) ;
/*
var MapQuest = new ol.layer.Group({
title: 'MapQuest layers',
layers: [
new ol.layer.Tile({type:'base',visible:false,title: 'MapQuest osm',source: new ol.source.MapQuest({layer: 'osm'}) }),
new ol.layer.Tile({type:'base',visible:false,title: 'MapQuest sat',source: new ol.source.MapQuest({layer: 'sat'}) }),
new ol.layer.Tile({type:'base',visible:false,title: 'MapQuest hyb',source: new ol.source.MapQuest({layer: 'hyb'}) })
] });
*/
var Mundialis = new ol.layer.Tile({
type:'base',
visible:true,
title: "Mundialis",
source: new ol.source.TileWMS({
url: 'http://ows.mundialis.de/services/service?',
params: {LAYERS: 'TOPO-WMS', TILED: true}
})
}) ;
var Bing = new ol.layer.Group({
title: 'Bing layers',
layers: [
new ol.layer.Tile({type:'base',visible:false,title: 'Bing aerial',source: new ol.source.BingMaps({key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', imagerySet: 'Aerial'}) }),
new ol.layer.Tile({type:'base',visible:false,title: 'Bing aerialwithlabels',source: new ol.source.BingMaps({key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', imagerySet: 'Aerialwithlabels'}) }),
new ol.layer.Tile({type:'base',visible:false,title: 'Bing roads',source: new ol.source.BingMaps({key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', imagerySet: 'Road'}) })
] });
var Stamen = new ol.layer.Group({
title: 'Stamen layers',
layers: [
new ol.layer.Tile({
type:'base',
visible:false,
title: 'Stamen watercolor',
source: new ol.source.Stamen({
layer: 'watercolor'
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'Stamen terrain',
source: new ol.source.Stamen({
layer: 'terrain'
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'Stamen toner',
source: new ol.source.Stamen({
layer: 'toner'
})
})
] });
// Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA
var OSM = new ol.layer.Group({
title: 'OSM layers',
layers: [
new ol.layer.Tile({
type:'base',
visible:false,
title: 'OSM satellite',
source: new ol.source.OSM({
layer: 'sat',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenstreeMap</a> contributors.'] })]
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'OSM cycles',
source: new ol.source.XYZ({
url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenstreeMap</a> contributors.'] })]
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'OSM humanitarian',
source: new ol.source.XYZ({
url: 'http://{a-c}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenstreeMap</a> contributors.'] })]
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'OSM transports',
source: new ol.source.XYZ({
url: 'http://tile.memomaps.de/tilegen/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenstreeMap</a> contributors.'] })]
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'OSM GPS',
source: new ol.source.XYZ({
url: 'https://gps-a.tile.openstreetmap.org/lines/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenstreeMap</a> contributors.'] })]
})
})
] });
var ESRI = new ol.layer.Group({
title: 'ESRI layers',
layers: [
new ol.layer.Tile({
type:'base',
visible:false,
title: 'ESRI Physical',
source: new ol.source.XYZ({
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/'+'World_Physical_Map/MapServer/tile/{z}/{y}/{x}',
attributions: [new ol.Attribution({ html: ['Tiles © <a href="http://services.arcgisonline.com/ArcGIS/' +
'rest/services/World_Topo_Map/MapServer">ArcGIS</a>'] })]
})
}),
new ol.layer.Tile({
type:'base',
visible:false,
title: 'ESRI Topo',
source: new ol.source.XYZ({
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/'+'World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
attributions: [new ol.Attribution({ html: ['Tiles © <a href="http://services.arcgisonline.com/ArcGIS/' +
'rest/services/World_Topo_Map/MapServer">ArcGIS</a>'] })]
})
}),
]
});
/*var Apple = new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_EN/{Z}/{X}/{Y}.png";'}),
title: 'Apple'
});*/
var NaturalEarth = new ol.layer.Tile({
title:'Natural Earth',
type: 'base',
visible: false,
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/' +'mapbox.natural-earth-hypso-bathy.jsonp',
crossOrigin: 'anonymous',
attributions: [new ol.Attribution({
//html: ['Tiles © <a href="http://here.com/">Nokia</a>']
})]
//attributions: [new ol.Attribution({ html: ['Tiles © <a href="http://here.com/">Nokia</a>'] })]
})
})
var Nokia = new ol.layer.Tile({
type:'base',
visible:false,
title: 'Nokia',
source: new ol.source.XYZ({
url: 'https://2.maps.nlp.nokia.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?lg=eng&token=A7tBPacePg9Mj_zghvKt9Q&app_id=KuYppsdXZznpffJsKT24',
attributions: [new ol.Attribution({
html: ['Tiles © <a href="http://here.com/">Nokia</a>']
})]
})
})
/* var thunderForest = new ol.layer.Tile({
type:'base',
visible:true,
title: 'thunderForest',
source: new ol.source.XYZ({
url: 'http://{s}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'] })]
})
})*/
var cartodb = new ol.layer.Tile({
type:'base',
visible:false,
title: 'cartodb',
source: new ol.source.XYZ({
url: 'https://cartocdn_a.global.ssl.fastly.net/base-light/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({ html: ['© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'] })]
})
})
//=======================================================================================================================================
//=======================================================================================================================================
//Additional layers
//=======================================================================================================================================
// WMS layer PREVIEW of cyclones risk
var cy_risk = new ol.layer.Tile({
title: "Cyclones risk",
visible: false,
source: new ol.source.TileWMS({
url: 'https://db1.unepgrid.ch/geoserver/wms',
params: {'LAYERS': 'preview:cy_risk'},
attributions: [new ol.Attribution({
html: '© '
+ '2013 '
+ '<a href="http://www.unep.org" target="_blank">'
+ 'UNEP</a>'
+ ' / '
+ '<a href="http://www.unisdr.org" target="_blank">'
+ 'UNISDR</a>'
+ ' |'
})]
})
});
// WMS layer PREVIEW of cyclones buffers
var cy_buffers = new ol.layer.Tile({
visible: false,
title: "Cyclones buffers",
source: new ol.source.TileWMS({
url: 'https://db1.unepgrid.ch/geoserver/wms',
params: {'LAYERS': 'preview:cy_buffers'},
attributions: [new ol.Attribution({
html: '© '
+ '2013 '
+ '<a href="http://www.unep.org" target="_blank">'
+ 'UNEP</a>'
+ ' / '
+ '<a href="http://www.unisdr.org" target="_blank">'
+ 'UNISDR</a>'
+ ' |'
})]
})
});
// WMS layer of rivers
var Rivers = new ol.layer.Tile({
title: "Rivers",
visible: false,
source: new ol.source.TileWMS({
url: 'https://db1.unepgrid.ch/geoserver/wms',
params: {'LAYERS': 'preview:Rivers'},
attributions: [new ol.Attribution({
html: '<a href="http://www.mapability.com/index1.html" target="_blank">'
+ 'VMAP0</a>'
+ ' / '
+ '<a href="http://www.esri.com/data/data-maps" target="_blank">'
+ 'ESRI</a>'
+ ' |'
})]
})
});
//=======================================================================================================================================
//CONTROLS
//=======================================================================================================================================
// Controls
var zoomSlider = new ol.control.ZoomSlider();
var scaleLineControl = new ol.control.ScaleLine();
var fullScreenControl = new ol.control.FullScreen();
var mousePositionControl = new ol.control.MousePosition({
coordinateFormat: ol.coordinate.createStringXY(4),
projection: 'EPSG:4326',
className: 'projMouse',
target: document.getElementById('projMouse'),
undefinedHTML: ' '
});
var layerSwitcher = new ol.control.LayerSwitcher();
//=======================================================================================================================================
//ICONS
//=======================================================================================================================================
iconStyle = new ol.style.Style({
image : new ol.style.Icon(({
anchor : [ 40, 46 ],
anchorXUnits : 'fraction',
anchorYUnits : 'pixels',
opacity : 1,
src : 'OL3/v3.4.0/examples/data/icon.png'
}))
});
vectorSource = new ol.source.Vector({
features : []
})
vectorLayer = new ol.layer.Vector({
source : vectorSource,
style : iconStyle
});
//=======================================================================================================================================
//MAP
//========================================================================================================================================
var map = new ol.Map({
// Linking the map with the HTML div
target: 'map',
// Adding layers to the map
layers: [
new ol.layer.Group({
title:'Base maps',
layers: [OSM, Stamen, Bing, ESRI, BlueMarble, cartodb, Nokia, Mundialis, NaturalEarth]
}),
new ol.layer.Group({
title:'Overlays',
layers: [cy_buffers, cy_risk, Rivers]
}),
new ol.layer.Group({
title:'Marker',
layers: [vectorLayer]
})
],
view: new ol.View({
center: ol.proj.transform([37.41, 8.82], 'EPSG:4326', 'EPSG:3857'), zoom: 4
}),
// Adding controls to the map
controls: ol.control.defaults().extend([
zoomSlider, scaleLineControl, fullScreenControl, mousePositionControl, layerSwitcher
])
});
</script>
</body>
</html>