1 var epsg4326 = new OpenLayers.Projection("EPSG:4326");
7 'openstreetmap.org': '2f59745a6b525b4ebdb100891d5b6711',
8 'www.openstreetmap.org': 'fd093e52f0965d46bb1c6c6281022199',
9 'openstreetmap.com': '4c60e7f5f31c576a9bb8da71c8d61152',
10 'www.openstreetmap.com': '142f25a0770a51a9a400b3513834a199',
11 'openstreetmap.net': '687c58fd1d715596bfc94abe653d8ac0',
12 'www.openstreetmap.net': '0bd1654141c85d30b9c2ccdb5302f2e4'
15 OpenLayers._getScriptLocation = function () {
16 return "/openlayers/";
19 function createMap(divName, options) {
20 options = options || {};
22 map = new OpenLayers.Map(divName, {
23 controls: options.controls || [
24 new OpenLayers.Control.ArgParser(),
25 new OpenLayers.Control.Attribution(),
26 new OpenLayers.Control.LayerSwitcher(),
27 new OpenLayers.Control.Navigation(),
28 new OpenLayers.Control.PanZoomBar(),
29 new OpenLayers.Control.ScaleLine()
32 maxResolution: 156543.0339,
34 displayProjection: new OpenLayers.Projection("EPSG:4326")
37 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
38 displayOutsideMaxExtent: true,
43 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
44 displayOutsideMaxExtent: true,
47 map.addLayer(osmarender);
49 var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle Map", {
50 displayOutsideMaxExtent: true,
53 map.addLayer(cyclemap);
55 var nonamekey = nonamekeys[document.domain];
56 var noname = new OpenLayers.Layer.OSM("NoName", [
57 "http://a.tile.cloudmade.com/" + nonamekey + "/3/256/",
58 "http://b.tile.cloudmade.com/" + nonamekey + "/3/256/",
59 "http://c.tile.cloudmade.com/" + nonamekey + "/3/256/"
61 displayOutsideMaxExtent: true,
67 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
68 displayOutsideMaxExtent: true,
71 map.addLayer(maplint);
73 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
74 markers = new OpenLayers.Layer.Markers("Markers", {
75 displayInLayerSwitcher: false,
76 numZoomLevels: numZoomLevels,
77 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
78 maxResolution: 156543,
80 projection: "EPSG:900913"
82 map.addLayer(markers);
87 function getArrowIcon() {
88 var size = new OpenLayers.Size(25, 22);
89 var offset = new OpenLayers.Pixel(-30, -27);
90 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
95 function addMarkerToMap(position, icon, description) {
96 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
98 markers.addMarker(marker);
101 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
107 function openMapPopup(marker, description) {
110 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
111 description, marker.icon, true);
112 popup.setBackgroundColor("#E3FFC5");
113 popup.autoSize = true;
119 function closeMapPopup() {
121 map.removePopup(popup);
126 function removeMarkerFromMap(marker){
127 markers.removeMarker(marker);
130 function getMapCenter(center, zoom) {
131 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
134 function setMapCenter(center, zoom) {
135 var numzoom = map.getNumZoomLevels();
136 if (zoom >= numzoom) zoom = numzoom - 1;
137 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
140 function setMapExtent(extent) {
141 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
144 function getMapExtent(extent) {
145 return map.getExtent().clone().transform(map.getProjectionObject(), epsg4326);
148 function getEventPosition(event) {
149 return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
152 function getMapLayers() {
153 var layerConfig = "";
155 for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
156 layerConfig += layers[i] == map.baseLayer ? "B" : "0";
159 for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
160 layerConfig += layers[i].getVisibility() ? "T" : "F";
166 function setMapLayers(layerConfig) {
169 for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
170 var c = layerConfig.charAt(l++);
173 map.setBaseLayer(layers[i]);
177 while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") {
181 for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
182 var c = layerConfig.charAt(l++);
185 layers[i].setVisibility(true);
186 } else if(c == "F") {
187 layers[i].setVisibility(false);
192 function scaleToZoom(scale) {
193 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);