[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 |
|
---|
| 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 fromProjection;
|
---|
| 22 | var toProjection;
|
---|
[5247] | 23 | var useTrace;
|
---|
| 24 | var zoom;
|
---|
[5208] | 25 |
|
---|
[5247] | 26 | function initialize(lat, lon, trace) {
|
---|
| 27 | useTrace = trace;
|
---|
| 28 |
|
---|
[5208] | 29 | map = new OpenLayers.Map("basicMap",
|
---|
| 30 | {controls:[
|
---|
| 31 | new OpenLayers.Control.Navigation(),
|
---|
| 32 | new OpenLayers.Control.PanZoomBar()]});
|
---|
| 33 | fromProjection = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
|
---|
| 34 | toProjection = new OpenLayers.Projection("EPSG:900913"); // Spherical Mercator
|
---|
[5247] | 35 | zoom = 0;
|
---|
[5208] | 36 |
|
---|
| 37 | var mapnik = new OpenLayers.Layer.OSM();
|
---|
| 38 | var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
|
---|
| 39 |
|
---|
| 40 | map.addLayer(mapnik);
|
---|
| 41 |
|
---|
| 42 | var size = new OpenLayers.Size(40,40);
|
---|
| 43 | var offset = new OpenLayers.Pixel(-size.w/2, -size.h/2);
|
---|
| 44 |
|
---|
[5212] | 45 | icon = new OpenLayers.Icon("qrc:///map/crosshair.png", size, offset);
|
---|
[5208] | 46 | markers = new OpenLayers.Layer.Markers("Markers");
|
---|
| 47 | marker = new OpenLayers.Marker(position, icon);
|
---|
| 48 | markers.addMarker(marker);
|
---|
| 49 |
|
---|
| 50 | map.addLayer(markers);
|
---|
| 51 |
|
---|
[5247] | 52 | map.setCenter(position, 3);
|
---|
[5208] | 53 | }
|
---|
| 54 |
|
---|
| 55 | function gotoLocation(lat, lon) {
|
---|
| 56 | var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
|
---|
[5247] | 57 | if (zoom == 0) {
|
---|
| 58 | zoom = 15;
|
---|
| 59 | map.setCenter(position, zoom);
|
---|
| 60 | }
|
---|
| 61 | else {
|
---|
| 62 | map.setCenter(position);
|
---|
| 63 | }
|
---|
[5208] | 64 | markers.removeMarker(marker);
|
---|
| 65 | marker = new OpenLayers.Marker(position, icon);
|
---|
| 66 | markers.addMarker(marker);
|
---|
[5248] | 67 | if (useTrace == 1) {
|
---|
| 68 | var trace = new OpenLayers.Marker(position);
|
---|
| 69 | markers.addMarker(trace);
|
---|
| 70 | }
|
---|
[5208] | 71 | }
|
---|
| 72 |
|
---|
| 73 | </script>
|
---|
| 74 |
|
---|
| 75 | </head>
|
---|
| 76 |
|
---|
| 77 | <body>
|
---|
| 78 | <div id="basicMap"></div>
|
---|
| 79 | </body>
|
---|
| 80 |
|
---|
| 81 | </html>
|
---|