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()
20 maxResolution: 156543,
24 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
25 displayOutsideMaxExtent: true,
30 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
31 displayOutsideMaxExtent: true,
34 map.addLayer(osmarender);
36 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
37 displayOutsideMaxExtent: true,
40 map.addLayer(maplint);
42 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
43 markers = new OpenLayers.Layer.Markers("Markers", {
44 displayInLayerSwitcher: false,
45 numZoomLevels: numZoomLevels,
46 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
47 maxResolution: 156543,
49 projection: "EPSG:900913"
51 map.addLayer(markers);
56 function getArrowIcon() {
57 var size = new OpenLayers.Size(25, 22);
58 var offset = new OpenLayers.Pixel(-30, -27);
59 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
64 function addMarkerToMap(position, icon, description) {
65 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
67 markers.addMarker(marker);
70 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
76 function openMapPopup(marker, description) {
79 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
80 description, marker.icon, true);
81 popup.setBackgroundColor("#E3FFC5");
82 popup.autoSize = true;
88 function closeMapPopup() {
90 map.removePopup(popup);
95 function removeMarkerFromMap(marker){
96 markers.removeMarker(marker);
99 function getMapCenter(center, zoom) {
100 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
103 function setMapCenter(center, zoom) {
104 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
107 function setMapExtent(extent) {
108 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
111 function getEventPosition(event) {
112 return map.getLonLatFromViewPortPx(e.xy).clone().transform(epsg4326, map.getProjectionObject());
115 function getMapLayers() {
118 for (var i=0; i< this.map.layers.length; i++) {
119 var layer = this.map.layers[i];
121 if (layer.isBaseLayer) {
122 layers += (layer == this.map.baseLayer) ? "B" : "0";
124 layers += (layer.getVisibility()) ? "T" : "F";
131 function setMapLayers(layers) {
132 for (var i=0; i < layers.length; i++) {
133 var layer = map.layers[i];
136 var c = layers.charAt(i);
139 map.setBaseLayer(layer);
140 } else if ( (c == "T") || (c == "F") ) {
141 layer.setVisibility(c == "T");
147 function scaleToZoom(scale) {
148 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);