5 OpenLayers._getScriptLocation = function () {
9 function createMap(divName) {
10 map = new OpenLayers.Map(divName, {
11 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
12 maxResolution: 156543,
14 projection: "EPSG:900913",
16 new OpenLayers.Control.ArgParser(),
17 new OpenLayers.Control.Attribution(),
18 new OpenLayers.Control.LayerSwitcher(),
19 new OpenLayers.Control.Navigation(),
20 new OpenLayers.Control.PanZoomBar()
24 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", { displayOutsideMaxExtent: true });
27 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", { displayOutsideMaxExtent: true });
28 map.addLayer(osmarender);
30 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", { displayOutsideMaxExtent: true });
31 map.addLayer(maplint);
33 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
34 markers = new OpenLayers.Layer.Markers("Markers", {
35 displayInLayerSwitcher: false,
36 numZoomLevels: numZoomLevels
38 map.addLayer(markers);
43 function getArrowIcon() {
44 var size = new OpenLayers.Size(25, 22);
45 var offset = new OpenLayers.Pixel(-30, -27);
46 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
51 function addMarkerToMap(position, icon, description) {
52 var marker = new OpenLayers.Marker(position, icon);
54 markers.addMarker(marker);
57 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
63 function openMapPopup(marker, description) {
66 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat,
67 sizeMapPopup(description),
68 "<p style='padding-right: 28px'>" + description + "</p>",
70 popup.setBackgroundColor("#E3FFC5");
76 function closeMapPopup() {
78 map.removePopup(popup);
83 function sizeMapPopup(text) {
84 var box = document.createElement("div");
87 box.style.visibility = "hidden";
88 box.style.position = "absolute";
89 box.style.top = "0px";
90 box.style.left = "0px";
91 box.style.width = "200px";
92 box.style.height = "auto";
94 document.body.appendChild(box);
96 var width = box.offsetWidth;
97 var height = box.offsetHeight;
99 document.body.removeChild(box);
101 return new OpenLayers.Size(width + 30, height + 24);
104 function removeMarkerFromMap(marker){
105 markers.removeMarker(marker);
108 function getMapLayers() {
111 for (var i=0; i< this.map.layers.length; i++) {
112 var layer = this.map.layers[i];
114 if (layer.isBaseLayer) {
115 layers += (layer == this.map.baseLayer) ? "B" : "0";
117 layers += (layer.getVisibility()) ? "T" : "F";
124 function setMapLayers(layers) {
125 for (var i=0; i < layers.length; i++) {
126 var layer = map.layers[i];
127 var c = layers.charAt(i);
130 map.setBaseLayer(layer);
131 } else if ( (c == "T") || (c == "F") ) {
132 layer.setVisibility(c == "T");
137 function mercatorToLonLat(merc) {
138 var lon = (merc.lon / 20037508.34) * 180;
139 var lat = (merc.lat / 20037508.34) * 180;
141 lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);
143 return new OpenLayers.LonLat(lon, lat);
146 function lonLatToMercator(ll) {
147 var lon = ll.lon * 20037508.34 / 180;
148 var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
150 lat = lat * 20037508.34 / 180;
152 return new OpenLayers.LonLat(lon, lat);
155 function scaleToZoom(scale) {
156 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);