[Mapbender-commits] r6635 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jul 26 05:44:35 EDT 2010
Author: verenadiewald
Date: 2010-07-26 09:44:35 +0000 (Mon, 26 Jul 2010)
New Revision: 6635
Added:
trunk/mapbender/http/plugins/mb_getApi.js
Removed:
trunk/mapbender/http/plugins/mb_getApi.js
Log:
api for GEORSS
Deleted: trunk/mapbender/http/plugins/mb_getApi.js
===================================================================
--- trunk/mapbender/http/plugins/mb_getApi.js 2010-07-26 09:41:04 UTC (rev 6634)
+++ trunk/mapbender/http/plugins/mb_getApi.js 2010-07-26 09:44:35 UTC (rev 6635)
@@ -1,141 +0,0 @@
-var $getApi = $(this);
-
-var GetApi = function (o) {
-
- var getParams = function () {
- var params = {};
-
- var getString = document.location.search.substr(1,document.location.search.length);
- if (getString === '') {
- return null;
- }
-
- var gArr = getString.split('&');
- for (i = 0; i < gArr.length; ++i) {
- var v = '';
- vArr = gArr[i].split('=');
- if (vArr.length > 1) {
- v = vArr[1];
- }
- var key = unescape(vArr[0]);
- params[key] = unescape(v);
- }
- return params;
- };
-
- var zoomToBbox = function (zoomBbox) {
- options.$target.each(function () {
- var mapObj = $(this).mapbender();
- if (mapObj.id.match(/^overview/)) {
- return;
- }
-
- if (mapObj === null) {
- var e = new Mb_exception("mb_getApi: unknown map object");
- return;
- }
-
- if (zoomBbox === "") {
- var e = new Mapbender.Notice("mb_getApi: no zoomBbox found.");
- return;
- }
- else {
- var zoomBboxParams = zoomBbox.split(",");
- var newExtent = new Mapbender.Extent(
- parseFloat(zoomBboxParams[0]),
- parseFloat(zoomBboxParams[1]),
- parseFloat(zoomBboxParams[2]),
- parseFloat(zoomBboxParams[3])
- );
- //check if EPSG param is given with ZOOM parameter
- if (zoomBboxParams.length === 5 && zoomBboxParams[4].match(/EPSG/)) {
- mapObj.transformCoords({
- extent : newExtent,
- crs : zoomBboxParams[4]
- });
- }
- else {
- mapObj.calculateExtent(newExtent);
- mapObj.setMapRequest();
- }
- }
- });
- };
-
- var params = getParams();
-
- Mapbender.events.init.register(function () {
- setCRS = function (params) {
- if (!params.CRS) {
- return;
- }
-
- options.$target.each(function () {
- var mapObj = $(this).mapbender();
- mapObj.setCrs({
- crs : params.CRS,
- callback : function () {
- setZOOM(params);
- }
- });
- });
- }
-
- setZOOM = function (params) {
- if (!params.ZOOM) {
- return;
- }
-
- options.$target.each(function () {
- var mapObj = $(this).mapbender();
- if (mapObj.id.match(/^overview/)) {
- return;
- }
-
- if (mapObj === null) {
- var e = new Mb_exception("mb_getApi: unknown map object");
- return;
- }
-
- var zoomParams = params.ZOOM.split(",");
-
- var epsg = "";
- if(zoomParams[zoomParams.length -1].match(/EPSG/)){
- epsg = zoomParams[zoomParams.length -1];
- zoomParams.pop();
- }
-
- if (zoomParams.length === 4) {
- var newExtent = new Mapbender.Extent(
- parseFloat(zoomParams[0]),
- parseFloat(zoomParams[1]),
- parseFloat(zoomParams[2]),
- parseFloat(zoomParams[3])
- );
-
- if (epsg) {
- mapObj.transformExtent({
- extent : newExtent,
- crs : epsg
- });
- }
- else {
- mapObj.calculateExtent(newExtent);
- mapObj.setMapRequest();
- }
- }
-
- //zoomParams contains 2 coordinates + scale (and optional EPSG param)
- if (zoomParams.length === 3) {
- mapObj.zoom(true, zoomParams[2], zoomParams[0], zoomParams[1], epsg);
- }
- });
- }
-
- setCRS(params);
- setZOOM(params);
- });
-
-};
-
-$getApi.mapbender(new GetApi(options));
Added: trunk/mapbender/http/plugins/mb_getApi.js
===================================================================
--- trunk/mapbender/http/plugins/mb_getApi.js (rev 0)
+++ trunk/mapbender/http/plugins/mb_getApi.js 2010-07-26 09:44:35 UTC (rev 6635)
@@ -0,0 +1,101 @@
+var $getApi = $(this);
+
+var GetApi = function (o) {
+
+ Mapbender.events.init.register(function () {
+ var setCRS = function (params) {
+ if (!params.CRS) {
+ return;
+ }
+
+ options.$target.each(function () {
+ var mapObj = $(this).mapbender();
+ mapObj.setCrs({
+ crs : params.CRS,
+ callback : function () {
+ setZOOM(params);
+ }
+ });
+ });
+ }
+
+ var setZOOM = function (params) {
+ if (!params.ZOOM) {
+ return;
+ }
+
+ options.$target.each(function () {
+ var mapObj = $(this).mapbender();
+ if (mapObj.id.match(/^overview/)) {
+ return;
+ }
+
+ if (mapObj === null) {
+ var e = new Mb_exception("mb_getApi: unknown map object");
+ return;
+ }
+
+ var zoomParams = params.ZOOM.split(",");
+
+ var epsg = "";
+ if(zoomParams[zoomParams.length -1].match(/EPSG/)){
+ epsg = zoomParams[zoomParams.length -1];
+ zoomParams.pop();
+ }
+
+ if (zoomParams.length === 4) {
+ var newExtent = new Mapbender.Extent(
+ parseFloat(zoomParams[0]),
+ parseFloat(zoomParams[1]),
+ parseFloat(zoomParams[2]),
+ parseFloat(zoomParams[3])
+ );
+
+ if (epsg) {
+ mapObj.transformExtent({
+ extent : newExtent,
+ crs : epsg
+ });
+ }
+ else {
+ mapObj.calculateExtent(newExtent);
+ mapObj.setMapRequest();
+ }
+ }
+
+ //zoomParams contains 2 coordinates + scale (and optional EPSG param)
+ if (zoomParams.length === 3) {
+ mapObj.zoom(true, zoomParams[2], zoomParams[0], zoomParams[1], epsg);
+ }
+ });
+ }
+
+ var setGEORSS = function (params) {
+ if (!params.GEORSS) {
+ return;
+ }
+
+ // array of georss
+ if(typeof params.GEORSS == 'object') {
+ for (var i = 0 ; i < params.GEORSS.length ; i++) {
+ options.$target.georss({
+ url : params.GEORSS[i]
+ });
+ }
+ }
+ // single georss
+ else {
+ options.$target.georss({
+ url : params.GEORSS
+ });
+ }
+ };
+
+ setCRS(getParams);
+ setZOOM(getParams);
+ setGEORSS(getParams);
+ });
+
+};
+
+$getApi.mapbender(new GetApi(options));
More information about the Mapbender_commits
mailing list