source: ntrip/trunk/BNC/src/map/map_osm.html@ 10514

Last change on this file since 10514 was 9422, checked in by stuerze, 4 years ago

some OSM updates to force https usage and a changed crossOriginKeyword

File size: 3.0 KB
RevLine 
[5208]1<!DOCTYPE HTML>
2<html>
3
4 <head>
5 <title>BNC OpenStreetMap View</title>
6 <style type="text/css">
7 html, body, #basicMap {
8 width: 100%;
9 height: 100%;
10 margin: 0;
11 }
12 </style>
13
[9422]14 <script src="https://openlayers.org/api/OpenLayers.js" ></script>
[5208]15
16 <script>
17 var map;
18 var markers;
19 var marker;
[9243]20 var icon;
[5251]21 var traceIcon;
[5208]22 var fromProjection;
23 var toProjection;
[5298]24 var dotSize;
[5307]25 var dotColor;
[5247]26 var zoom;
[5208]27
[5307]28 function initialize(lat, lon, mapWinDotSize, mapWinDotColor) {
29 dotSize = mapWinDotSize;
[9243]30 dotColor = mapWinDotColor;
[5307]31
[5302]32 if (dotSize > 10) dotSize = 10;
[5247]33
[5208]34 map = new OpenLayers.Map("basicMap",
35 {controls:[
36 new OpenLayers.Control.Navigation(),
37 new OpenLayers.Control.PanZoomBar()]});
38 fromProjection = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
39 toProjection = new OpenLayers.Projection("EPSG:900913"); // Spherical Mercator
[9243]40 zoom = 0;
[5208]41
[9422]42 map.addLayer(new OpenLayers.Layer.OSM("OpenStreetMap",
43 // Official OSM tileset as forced HTTPS URLs
44 [ 'https://a.tile.openstreetmap.de/${z}/${x}/${y}.png',
45 'https://b.tile.openstreetmap.de/${z}/${x}/${y}.png',
46 'https://c.tile.openstreetmap.de/${z}/${x}/${y}.png'
47 ],{tileOptions : {crossOriginKeyword: null}}));
48
[5208]49 var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
50
51 var size = new OpenLayers.Size(40,40);
52 var offset = new OpenLayers.Pixel(-size.w/2, -size.h/2);
[5251]53 icon = new OpenLayers.Icon("qrc:///map/crosshair.png", size, offset);
[5208]54
[5298]55 var sizeT = new OpenLayers.Size(dotSize,dotSize);
[9243]56 var offsetT = new OpenLayers.Pixel(-sizeT.w/2, -13);
57 if (dotColor == 1) {
[5307]58 traceIcon = new OpenLayers.Icon("qrc:///map/reddot.png", sizeT, offsetT);
[9243]59 }
60 if (dotColor == 2) {
[5307]61 traceIcon = new OpenLayers.Icon("qrc:///map/yellowdot.png", sizeT, offsetT);
[9243]62 }
[5251]63
[5208]64 markers = new OpenLayers.Layer.Markers("Markers");
65 marker = new OpenLayers.Marker(position, icon);
66 markers.addMarker(marker);
[9243]67
[5208]68 map.addLayer(markers);
69
[5247]70 map.setCenter(position, 3);
[5208]71 }
72
73 function gotoLocation(lat, lon) {
74 var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
[5247]75 if (zoom == 0) {
76 zoom = 15;
77 map.setCenter(position, zoom);
78 }
79 else {
80 map.setCenter(position);
81 }
[5208]82 markers.removeMarker(marker);
83 marker = new OpenLayers.Marker(position, icon);
84 markers.addMarker(marker);
[5298]85 if (dotSize > 0) {
[5254]86 var trace = new OpenLayers.Marker(position, traceIcon.clone());
[5248]87 markers.addMarker(trace);
88 }
[5208]89 }
90
91 </script>
92
93 </head>
94
95 <body>
96 <div id="basicMap"></div>
97 </body>
98
99</html>
Note: See TracBrowser for help on using the repository browser.