-function mercatorToLonLat(merc) {
- var lon = (merc.lon / 20037508.34) * 180;
- var lat = (merc.lat / 20037508.34) * 180;
- var PI = 3.14159265358979323846;
+function getMapCenter(center, zoom) {
+ return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326);
+}
+
+function setMapCenter(center, zoom) {
+ map.setCenter(center.clone().transform(epsg4326, map.getProjectionObject()), zoom);
+}
+
+function setMapExtent(extent) {
+ map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject()));
+}
+
+function getMapExtent(extent) {
+ return map.getExtent().clone().transform(map.getProjectionObject(), epsg4326);
+}
+
+function getEventPosition(event) {
+ return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
+}
+
+function getMapLayers() {
+ var layerConfig = "";
+
+ for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
+ layerConfig += layers[i] == map.baseLayer ? "B" : "0";
+ }