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);
44 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
45 markers = new OpenLayers.Layer.Markers("Markers", {
46 displayInLayerSwitcher: false,
47 numZoomLevels: numZoomLevels,
48 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
49 maxResolution: 156543,
51 projection: "EPSG:900913"
53 map.addLayer(markers);
58 function getArrowIcon() {
59 var size = new OpenLayers.Size(25, 22);
60 var offset = new OpenLayers.Pixel(-30, -27);
61 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
66 function addMarkerToMap(position, icon, description) {
67 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
69 markers.addMarker(marker);
72 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
78 function openMapPopup(marker, description) {
81 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
82 description, marker.icon, true);
83 popup.setBackgroundColor("#E3FFC5");
84 popup.autoSize = true;
90 function closeMapPopup() {
92 map.removePopup(popup);
97 function removeMarkerFromMap(marker){
98 markers.removeMarker(marker);
101 function getMapCenter(center, zoom) {
102 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
105 function setMapCenter(center, zoom) {
106 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
109 function setMapExtent(extent) {
110 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
113 function getEventPosition(event) {
114 return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
117 function getMapLayers() {
120 for (var i=0; i< this.map.layers.length; i++) {
121 var layer = this.map.layers[i];
123 if (layer.isBaseLayer) {
124 layers += (layer == this.map.baseLayer) ? "B" : "0";
126 layers += (layer.getVisibility()) ? "T" : "F";
133 function setMapLayers(layers) {
134 for (var i=0; i < layers.length; i++) {
135 var layer = map.layers[i];
138 var c = layers.charAt(i);
141 map.setBaseLayer(layer);
142 } else if ( (c == "T") || (c == "F") ) {
143 layer.setVisibility(c == "T");
149 function scaleToZoom(scale) {
150 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);