1 var epsg4326 = new OpenLayers.Projection("EPSG:4326");
6 OpenLayers._getScriptLocation = function () {
10 function createMap(divName) {
11 map = new OpenLayers.Map(divName, {
13 new OpenLayers.Control.ArgParser(),
14 new OpenLayers.Control.Attribution(),
15 new OpenLayers.Control.LayerSwitcher(),
16 new OpenLayers.Control.Navigation(),
17 new OpenLayers.Control.PanZoomBar(),
18 new OpenLayers.Control.ScaleLine()
21 maxResolution: 156543,
25 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
26 displayOutsideMaxExtent: true,
31 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
32 displayOutsideMaxExtent: true,
35 map.addLayer(osmarender);
37 var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle Map", {
38 displayOutsideMaxExtent: true,
41 map.addLayer(cyclemap);
43 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
44 displayOutsideMaxExtent: true,
47 map.addLayer(maplint);
49 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
50 markers = new OpenLayers.Layer.Markers("Markers", {
51 displayInLayerSwitcher: false,
52 numZoomLevels: numZoomLevels,
53 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
54 maxResolution: 156543,
56 projection: "EPSG:900913"
58 map.addLayer(markers);
63 function getArrowIcon() {
64 var size = new OpenLayers.Size(25, 22);
65 var offset = new OpenLayers.Pixel(-30, -27);
66 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
71 function addMarkerToMap(position, icon, description) {
72 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
74 markers.addMarker(marker);
77 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
83 function openMapPopup(marker, description) {
86 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
87 description, marker.icon, true);
88 popup.setBackgroundColor("#E3FFC5");
89 popup.autoSize = true;
95 function closeMapPopup() {
97 map.removePopup(popup);
102 function removeMarkerFromMap(marker){
103 markers.removeMarker(marker);
106 function getMapCenter(center, zoom) {
107 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
110 function setMapCenter(center, zoom) {
111 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
114 function setMapExtent(extent) {
115 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
118 function getMapExtent(extent) {
119 return map.getExtent().clone().transform(map.getProjectionObject(), epsg4326);
122 function getEventPosition(event) {
123 return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
126 function getMapLayers() {
127 var layerConfig = "";
129 for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
130 layerConfig += layers[i] == map.baseLayer ? "B" : "0";
133 for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
134 layerConfig += layers[i].getVisibility() ? "T" : "F";
140 function setMapLayers(layerConfig) {
143 for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
144 var c = layerConfig.charAt(l++);
147 map.setBaseLayer(layers[i]);
151 while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") {
155 for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
156 var c = layerConfig.charAt(l++);
159 layers[i].setVisibility(true);
160 } else if(c == "F") {
161 layers[i].setVisibility(false);
166 function scaleToZoom(scale) {
167 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);