5 OpenLayers._getScriptLocation = function () {
9 function createMap(divName) {
10 map = new OpenLayers.Map(divName);
12 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", { displayOutsideMaxExtent: true });
15 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", { displayOutsideMaxExtent: true });
16 map.addLayer(osmarender);
18 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
19 markers = new OpenLayers.Layer.Markers("Markers", { visibility: false, numZoomLevels: numZoomLevels });
20 map.addLayer(markers);
22 map.addControl(new OpenLayers.Control.LayerSwitcher());
23 map.addControl(new OpenLayers.Control.KeyboardDefaults());
28 function getArrowIcon() {
29 var size = new OpenLayers.Size(25, 22);
30 var offset = new OpenLayers.Pixel(-30, -27);
31 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
36 function addMarkerToMap(position, icon, description) {
37 var marker = new OpenLayers.Marker(position, icon);
39 markers.addMarker(marker);
40 markers.setVisibility(true);
43 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
49 function openMapPopup(marker, description) {
52 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat,
53 sizeMapPopup(description),
54 "<p style='padding-right: 28px'>" + description + "</p>",
56 popup.setBackgroundColor("#E3FFC5");
62 function closeMapPopup() {
64 map.removePopup(popup);
69 function sizeMapPopup(text) {
70 var box = document.createElement("div");
73 box.style.visibility = "hidden";
74 box.style.position = "absolute";
75 box.style.top = "0px";
76 box.style.left = "0px";
77 box.style.width = "200px";
78 box.style.height = "auto";
80 document.body.appendChild(box);
82 var width = box.offsetWidth;
83 var height = box.offsetHeight;
85 document.body.removeChild(box);
87 return new OpenLayers.Size(width + 30, height + 24);
90 function removeMarkerFromMap(marker){
91 markers.removeMarker(marker);
94 function getMapLayers() {
97 for (var i=0; i< this.map.layers.length; i++) {
98 var layer = this.map.layers[i];
100 if (layer.isBaseLayer) {
101 layers += (layer == this.map.baseLayer) ? "B" : "0";
103 layers += (layer.getVisibility()) ? "T" : "F";
110 function setMapLayers(layers) {
111 for (var i=0; i < layers.length; i++) {
112 var layer = map.layers[i];
113 var c = layers.charAt(i);
116 map.setBaseLayer(layer);
117 } else if ( (c == "T") || (c == "F") ) {
118 layer.setVisibility(c == "T");
123 function mercatorToLonLat(merc) {
124 var lon = (merc.lon / 20037508.34) * 180;
125 var lat = (merc.lat / 20037508.34) * 180;
127 lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);
129 return new OpenLayers.LonLat(lon, lat);
132 function lonLatToMercator(ll) {
133 var lon = ll.lon * 20037508.34 / 180;
134 var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
136 lat = lat * 20037508.34 / 180;
138 return new OpenLayers.LonLat(lon, lat);
141 function scaleToZoom(scale) {
142 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);