1 var epsg4326 = new OpenLayers.Projection("EPSG:4326");
6 OpenLayers._getScriptLocation = function () {
10 function createMap(divName, options) {
11 options = options || {};
13 map = new OpenLayers.Map(divName, {
14 controls: options.controls || [
15 new OpenLayers.Control.ArgParser(),
16 new OpenLayers.Control.Attribution(),
17 new OpenLayers.Control.LayerSwitcher(),
18 new OpenLayers.Control.Navigation(),
19 new OpenLayers.Control.PanZoomBar(),
20 new OpenLayers.Control.ScaleLine()
23 maxResolution: 156543.0339,
27 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
28 displayOutsideMaxExtent: true,
33 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
34 displayOutsideMaxExtent: true,
37 map.addLayer(osmarender);
39 var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle Map", {
40 displayOutsideMaxExtent: true,
43 map.addLayer(cyclemap);
45 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
46 displayOutsideMaxExtent: true,
49 map.addLayer(maplint);
51 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
52 markers = new OpenLayers.Layer.Markers("Markers", {
53 displayInLayerSwitcher: false,
54 numZoomLevels: numZoomLevels,
55 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
56 maxResolution: 156543,
58 projection: "EPSG:900913"
60 map.addLayer(markers);
65 function getArrowIcon() {
66 var size = new OpenLayers.Size(25, 22);
67 var offset = new OpenLayers.Pixel(-30, -27);
68 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
73 function addMarkerToMap(position, icon, description) {
74 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
76 markers.addMarker(marker);
79 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
85 function openMapPopup(marker, description) {
88 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
89 description, marker.icon, true);
90 popup.setBackgroundColor("#E3FFC5");
91 popup.autoSize = true;
97 function closeMapPopup() {
99 map.removePopup(popup);
104 function removeMarkerFromMap(marker){
105 markers.removeMarker(marker);
108 function getMapCenter(center, zoom) {
109 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
112 function setMapCenter(center, zoom) {
113 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
116 function setMapExtent(extent) {
117 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
120 function getMapExtent(extent) {
121 return map.getExtent().clone().transform(map.getProjectionObject(), epsg4326);
124 function getEventPosition(event) {
125 return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
128 function getMapLayers() {
129 var layerConfig = "";
131 for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
132 layerConfig += layers[i] == map.baseLayer ? "B" : "0";
135 for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
136 layerConfig += layers[i].getVisibility() ? "T" : "F";
142 function setMapLayers(layerConfig) {
145 for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
146 var c = layerConfig.charAt(l++);
149 map.setBaseLayer(layers[i]);
153 while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") {
157 for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
158 var c = layerConfig.charAt(l++);
161 layers[i].setVisibility(true);
162 } else if(c == "F") {
163 layers[i].setVisibility(false);
168 function scaleToZoom(scale) {
169 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);