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

Last change on this file since 5302 was 5302, checked in by weber, 9 years ago

Dot size maximum introduced

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