5 OpenLayers._getScriptLocation = function () {
9 function createMap(divName) {
10 map = new OpenLayers.Map(divName, {
12 new OpenLayers.Control.ArgParser(),
13 new OpenLayers.Control.Attribution(),
14 new OpenLayers.Control.LayerSwitcher(),
15 new OpenLayers.Control.Navigation(),
16 new OpenLayers.Control.PanZoomBar()
20 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", { displayOutsideMaxExtent: true });
23 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", { displayOutsideMaxExtent: true });
24 map.addLayer(osmarender);
26 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", { displayOutsideMaxExtent: true });
27 map.addLayer(maplint);
29 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
30 markers = new OpenLayers.Layer.Markers("Markers", {
31 displayInLayerSwitcher: false, numZoomLevels: numZoomLevels,
32 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
33 maxResolution: 156543,
35 projection: "EPSG:41001"
37 map.addLayer(markers);
42 function getArrowIcon() {
43 var size = new OpenLayers.Size(25, 22);
44 var offset = new OpenLayers.Pixel(-30, -27);
45 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
50 function addMarkerToMap(position, icon, description) {
51 var marker = new OpenLayers.Marker(position, icon);
53 markers.addMarker(marker);
56 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
62 function openMapPopup(marker, description) {
65 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat,
66 sizeMapPopup(description),
67 "<p style='padding-right: 28px'>" + description + "</p>",
69 popup.setBackgroundColor("#E3FFC5");
75 function closeMapPopup() {
77 map.removePopup(popup);
82 function sizeMapPopup(text) {
83 var box = document.createElement("div");
86 box.style.visibility = "hidden";
87 box.style.position = "absolute";
88 box.style.top = "0px";
89 box.style.left = "0px";
90 box.style.width = "200px";
91 box.style.height = "auto";
93 document.body.appendChild(box);
95 var width = box.offsetWidth;
96 var height = box.offsetHeight;
98 document.body.removeChild(box);
100 return new OpenLayers.Size(width + 30, height + 24);
103 function removeMarkerFromMap(marker){
104 markers.removeMarker(marker);
107 function getMapLayers() {
110 for (var i=0; i< this.map.layers.length; i++) {
111 var layer = this.map.layers[i];
113 if (layer.isBaseLayer) {
114 layers += (layer == this.map.baseLayer) ? "B" : "0";
116 layers += (layer.getVisibility()) ? "T" : "F";
123 function setMapLayers(layers) {
124 for (var i=0; i < layers.length; i++) {
125 var layer = map.layers[i];
126 var c = layers.charAt(i);
129 map.setBaseLayer(layer);
130 } else if ( (c == "T") || (c == "F") ) {
131 layer.setVisibility(c == "T");
136 function mercatorToLonLat(merc) {
137 var lon = (merc.lon / 20037508.34) * 180;
138 var lat = (merc.lat / 20037508.34) * 180;
140 lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);
142 return new OpenLayers.LonLat(lon, lat);
145 function lonLatToMercator(ll) {
146 var lon = ll.lon * 20037508.34 / 180;
147 var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
149 lat = lat * 20037508.34 / 180;
151 return new OpenLayers.LonLat(lon, lat);
154 function scaleToZoom(scale) {
155 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);