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 maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
38 displayOutsideMaxExtent: true,
41 map.addLayer(maplint);
43 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
44 markers = new OpenLayers.Layer.Markers("Markers", {
45 displayInLayerSwitcher: false,
46 numZoomLevels: numZoomLevels,
47 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
48 maxResolution: 156543,
50 projection: "EPSG:900913"
52 map.addLayer(markers);
57 function getArrowIcon() {
58 var size = new OpenLayers.Size(25, 22);
59 var offset = new OpenLayers.Pixel(-30, -27);
60 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
65 function addMarkerToMap(position, icon, description) {
66 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
68 markers.addMarker(marker);
71 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
77 function openMapPopup(marker, description) {
80 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
81 description, marker.icon, true);
82 popup.setBackgroundColor("#E3FFC5");
83 popup.autoSize = true;
89 function closeMapPopup() {
91 map.removePopup(popup);
96 function removeMarkerFromMap(marker){
97 markers.removeMarker(marker);
100 function getMapCenter(center, zoom) {
101 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
104 function setMapCenter(center, zoom) {
105 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
108 function setMapExtent(extent) {
109 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
112 function getMapExtent(extent) {
113 return map.getExtent().clone().transform(map.getProjectionObject(), epsg4326);
116 function getEventPosition(event) {
117 return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
120 function getMapLayers() {
123 for (var i=0; i< this.map.layers.length; i++) {
124 var layer = this.map.layers[i];
126 if (layer.isBaseLayer) {
127 layers += (layer == this.map.baseLayer) ? "B" : "0";
129 layers += (layer.getVisibility()) ? "T" : "F";
136 function setMapLayers(layers) {
137 for (var i=0; i < layers.length; i++) {
138 var layer = map.layers[i];
141 var c = layers.charAt(i);
144 map.setBaseLayer(layer);
145 } else if ( (c == "T") || (c == "F") ) {
146 layer.setVisibility(c == "T");
152 function scaleToZoom(scale) {
153 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);