1 var epsg4326 = new OpenLayers.Projection("EPSG:4326");
6 OpenLayers._getScriptLocation = function () {
10 function createMap(divName, options) {
11 if (!options) { options = {} }
12 map = new OpenLayers.Map(divName, {
13 controls: options.controls || [
14 new OpenLayers.Control.ArgParser(),
15 new OpenLayers.Control.Attribution(),
16 new OpenLayers.Control.LayerSwitcher(),
17 new OpenLayers.Control.Navigation(),
18 new OpenLayers.Control.PanZoomBar(),
19 new OpenLayers.Control.ScaleLine()
22 maxResolution: 156543.0339,
26 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
27 displayOutsideMaxExtent: true,
32 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
33 displayOutsideMaxExtent: true,
36 map.addLayer(osmarender);
38 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
39 displayOutsideMaxExtent: true,
42 map.addLayer(maplint);
43 var data = new OpenLayers.Layer.Data("Data", {'visibility': false});
47 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
48 markers = new OpenLayers.Layer.Markers("Markers", {
49 displayInLayerSwitcher: false,
50 numZoomLevels: numZoomLevels,
51 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
52 maxResolution: 156543,
54 projection: "EPSG:900913"
56 map.addLayer(markers);
61 function getArrowIcon() {
62 var size = new OpenLayers.Size(25, 22);
63 var offset = new OpenLayers.Pixel(-30, -27);
64 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
69 function addMarkerToMap(position, icon, description) {
70 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
72 markers.addMarker(marker);
75 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
81 function openMapPopup(marker, description) {
84 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
85 description, marker.icon, true);
86 popup.setBackgroundColor("#E3FFC5");
87 popup.autoSize = true;
93 function closeMapPopup() {
95 map.removePopup(popup);
100 function removeMarkerFromMap(marker){
101 markers.removeMarker(marker);
104 function getMapCenter(center, zoom) {
105 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
108 function setMapCenter(center, zoom) {
109 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
112 function setMapExtent(extent) {
113 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
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);