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 maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", { displayOutsideMaxExtent: true });
19 map.addLayer(maplint);
21 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
22 markers = new OpenLayers.Layer.Markers("Markers", {
23 displayInLayerSwitcher: false, numZoomLevels: numZoomLevels,
24 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
25 maxResolution: 156543,
27 projection: "EPSG:41001"
29 map.addLayer(markers);
31 map.addControl(new OpenLayers.Control.LayerSwitcher());
32 map.addControl(new OpenLayers.Control.KeyboardDefaults());
37 function getArrowIcon() {
38 var size = new OpenLayers.Size(25, 22);
39 var offset = new OpenLayers.Pixel(-30, -27);
40 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
45 function addMarkerToMap(position, icon, description) {
46 var marker = new OpenLayers.Marker(position, icon);
48 markers.addMarker(marker);
51 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
57 function openMapPopup(marker, description) {
60 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat,
61 sizeMapPopup(description),
62 "<p style='padding-right: 28px'>" + description + "</p>",
64 popup.setBackgroundColor("#E3FFC5");
70 function closeMapPopup() {
72 map.removePopup(popup);
77 function sizeMapPopup(text) {
78 var box = document.createElement("div");
81 box.style.visibility = "hidden";
82 box.style.position = "absolute";
83 box.style.top = "0px";
84 box.style.left = "0px";
85 box.style.width = "200px";
86 box.style.height = "auto";
88 document.body.appendChild(box);
90 var width = box.offsetWidth;
91 var height = box.offsetHeight;
93 document.body.removeChild(box);
95 return new OpenLayers.Size(width + 30, height + 24);
98 function removeMarkerFromMap(marker){
99 markers.removeMarker(marker);
102 function getMapLayers() {
105 for (var i=0; i< this.map.layers.length; i++) {
106 var layer = this.map.layers[i];
108 if (layer.isBaseLayer) {
109 layers += (layer == this.map.baseLayer) ? "B" : "0";
111 layers += (layer.getVisibility()) ? "T" : "F";
118 function setMapLayers(layers) {
119 for (var i=0; i < layers.length; i++) {
120 var layer = map.layers[i];
121 var c = layers.charAt(i);
124 map.setBaseLayer(layer);
125 } else if ( (c == "T") || (c == "F") ) {
126 layer.setVisibility(c == "T");
131 function mercatorToLonLat(merc) {
132 var lon = (merc.lon / 20037508.34) * 180;
133 var lat = (merc.lat / 20037508.34) * 180;
135 lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);
137 return new OpenLayers.LonLat(lon, lat);
140 function lonLatToMercator(ll) {
141 var lon = ll.lon * 20037508.34 / 180;
142 var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
144 lat = lat * 20037508.34 / 180;
146 return new OpenLayers.LonLat(lon, lat);
149 function scaleToZoom(scale) {
150 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);