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

Last change on this file since 5254 was 5254, checked in by mervart, 11 years ago
File size: 2.4 KB
Line 
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
14 <script src="http://openlayers.org/api/OpenLayers.js" ></script>
15
16 <script>
17 var map;
18 var markers;
19 var marker;
20 var icon;
21 var traceIcon;
22 var fromProjection;
23 var toProjection;
24 var useTrace;
25 var zoom;
26
27 function initialize(lat, lon, trace) {
28 useTrace = trace;
29
30 map = new OpenLayers.Map("basicMap",
31 {controls:[
32 new OpenLayers.Control.Navigation(),
33 new OpenLayers.Control.PanZoomBar()]});
34 fromProjection = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
35 toProjection = new OpenLayers.Projection("EPSG:900913"); // Spherical Mercator
36 zoom = 0;
37
38 var mapnik = new OpenLayers.Layer.OSM();
39 var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
40
41 map.addLayer(mapnik);
42
43 var size = new OpenLayers.Size(40,40);
44 var offset = new OpenLayers.Pixel(-size.w/2, -size.h/2);
45 icon = new OpenLayers.Icon("qrc:///map/crosshair.png", size, offset);
46
47 var sizeT = new OpenLayers.Size(2,2);
48 var offsetT = new OpenLayers.Pixel(-sizeT.w/2, -13);
49 traceIcon = new OpenLayers.Icon("qrc:///map/reddot.png", sizeT, offsetT);
50
51 markers = new OpenLayers.Layer.Markers("Markers");
52 marker = new OpenLayers.Marker(position, icon);
53 markers.addMarker(marker);
54
55 map.addLayer(markers);
56
57 map.setCenter(position, 3);
58 }
59
60 function gotoLocation(lat, lon) {
61 var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
62 if (zoom == 0) {
63 zoom = 15;
64 map.setCenter(position, zoom);
65 }
66 else {
67 map.setCenter(position);
68 }
69 markers.removeMarker(marker);
70 marker = new OpenLayers.Marker(position, icon);
71 markers.addMarker(marker);
72 if (useTrace == 1) {
73 var trace = new OpenLayers.Marker(position, traceIcon.clone());
74 markers.addMarker(trace);
75 }
76 }
77
78 </script>
79
80 </head>
81
82 <body>
83 <div id="basicMap"></div>
84 </body>
85
86</html>
Note: See TracBrowser for help on using the repository browser.