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()
23 var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
24 displayOutsideMaxExtent: true,
29 var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
30 displayOutsideMaxExtent: true,
33 map.addLayer(osmarender);
35 var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
36 displayOutsideMaxExtent: true,
39 map.addLayer(maplint);
41 var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
42 markers = new OpenLayers.Layer.Markers("Markers", {
43 displayInLayerSwitcher: false,
44 numZoomLevels: numZoomLevels,
45 maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
46 maxResolution: 156543,
48 projection: "EPSG:900913"
50 map.addLayer(markers);
55 function getArrowIcon() {
56 var size = new OpenLayers.Size(25, 22);
57 var offset = new OpenLayers.Pixel(-30, -27);
58 var icon = new OpenLayers.Icon("/images/arrow.png", size, offset);
63 function addMarkerToMap(position, icon, description) {
64 var marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
66 markers.addMarker(marker);
69 marker.events.register("click", marker, function() { openMapPopup(marker, description) });
75 function openMapPopup(marker, description) {
78 popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null,
79 description, marker.icon, true);
80 popup.setBackgroundColor("#E3FFC5");
81 popup.autoSize = true;
87 function closeMapPopup() {
89 map.removePopup(popup);
94 function removeMarkerFromMap(marker){
95 markers.removeMarker(marker);
98 function getMapCenter(center, zoom) {
99 return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
102 function setMapCenter(center, zoom) {
103 map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
106 function setMapExtent(extent) {
107 map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
110 function getEventPosition(event) {
111 return map.getLonLatFromViewPortPx(e.xy).clone().transform(epsg4326, map.getProjectionObject());
114 function getMapLayers() {
117 for (var i=0; i< this.map.layers.length; i++) {
118 var layer = this.map.layers[i];
120 if (layer.isBaseLayer) {
121 layers += (layer == this.map.baseLayer) ? "B" : "0";
123 layers += (layer.getVisibility()) ? "T" : "F";
130 function setMapLayers(layers) {
131 for (var i=0; i < layers.length; i++) {
132 var layer = map.layers[i];
133 var c = layers.charAt(i);
136 map.setBaseLayer(layer);
137 } else if ( (c == "T") || (c == "F") ) {
138 layer.setVisibility(c == "T");
143 function scaleToZoom(scale) {
144 return Math.log(360.0/(scale * 512.0)) / Math.log(2.0);