[Mapbender-commits] r6559 - in trunk/mapbender/http: javascripts
plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sun Jul 4 06:32:43 EDT 2010
Author: christoph
Date: 2010-07-04 10:32:43 +0000 (Sun, 04 Jul 2010)
New Revision: 6559
Modified:
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/mod_dragMapSize.php
trunk/mapbender/http/plugins/mb_overview.js
Log:
http://trac.osgeo.org/mapbender/ticket/657
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2010-07-04 10:24:00 UTC (rev 6558)
+++ trunk/mapbender/http/javascripts/map_obj.js 2010-07-04 10:32:43 UTC (rev 6559)
@@ -484,7 +484,11 @@
* @type string
*/
this.getExtent = function(){
- return this.extent.toString();
+ var ext = this.extent;
+ if (ext) {
+ return ext.toString();
+ }
+ return "";
};
/**
@@ -494,8 +498,11 @@
* @type Object
*/
this.getExtentInfos = function(){
- var c = this.extent.toString().split(",");
- var ext = new Mapbender.Extent(c[0], c[1], c[2], c[3]);
+ var c = this.getExtent().split(",");
+ if (typeof c !== "object" || c.length !== 4) {
+ return null;
+ }
+ var ext = new Mapbender.Extent(c[0], c[1], c[2], c[3]);
return ext;
};
@@ -608,11 +615,14 @@
this.zoomFull = function(){
- if (this.restrictedExtent) {
- this.calculateExtent(this.restrictedExtent);
- this.setMapRequest();
- }
- else {
+// if (this.restrictedExtent) {
+// this.calculateExtent(this.restrictedExtent);
+// this.setMapRequest();
+// }
+// else {
+ if (typeof this.wms !== "object" || this.wms.length === 0) {
+ return;
+ }
for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
if (this.epsg == this.wms[0].gui_epsg[i]) {
var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
@@ -626,7 +636,7 @@
break;
}
}
- }
+// }
};
this.calculateExtentAfterZoom = function (in_, factor, x, y) {
@@ -708,7 +718,10 @@
}
else {
arrayBBox = this.getExtent().split(",");
- }
+ if (typeof arrayBBox !== "object" || arrayBBox.length !== 4) {
+ return new Mapbender.Point(0,0);
+ }
+ }
var minX = parseFloat(arrayBBox[0]);
var minY = parseFloat(arrayBBox[1]);
var maxX = parseFloat(arrayBBox[2]);
@@ -907,26 +920,28 @@
* @return scale
* @type integer
*/
- this.getScale = function(){
+ this.getScale = function(){
var scale;
- var bbox = this.extent.toString().split(",");
- if (this.epsg == "EPSG:4326") {
- // xl_length and yl_length refers to linear widths on horizontal and vertical axes
- var xl_length=(parseFloat(bbox[3]) - parseFloat(bbox[1]));
- var yl_length=(parseFloat(bbox[2]) - parseFloat(bbox[0]));
-
- // xa_length and ya_length refers to angular width on horizontal and vertical axes
- var xa_length=(xl_length*360)/(2*Math.PI*6378137);
- var ya_length=(xl_length*360)/(2*Math.PI*6378137);
-
- scale=((xl_length/this.getHeight())/mb_resolution);
- }
-
- else {
- xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
- scale = (xtenty / this.getHeight()) * (mb_resolution * 100);
- }
-
+ var bbox = this.getExtent().split(",");
+ if (typeof bbox !== "object" || bbox.length !== 4) {
+ return null;
+ }
+ if (this.epsg == "EPSG:4326") {
+ // xl_length and yl_length refers to linear widths on horizontal and vertical axes
+ var xl_length=(parseFloat(bbox[3]) - parseFloat(bbox[1]));
+ var yl_length=(parseFloat(bbox[2]) - parseFloat(bbox[0]));
+
+ // xa_length and ya_length refers to angular width on horizontal and vertical axes
+ var xa_length=(xl_length*360)/(2*Math.PI*6378137);
+ var ya_length=(xl_length*360)/(2*Math.PI*6378137);
+
+ scale=((xl_length/this.getHeight())/mb_resolution);
+ }
+ else {
+ xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
+ scale = (xtenty / this.getHeight()) * (mb_resolution * 100);
+ }
+
return parseInt(Math.round(scale), 10);
};
@@ -1324,7 +1339,11 @@
};
this.setMapRequest = function(wmsArray){
- // initialize history
+ if (!wms || wms.length === 0) {
+ return;
+ }
+
+ // initialize history
(function(){
var extent = new Extent(that.extent);
if (typeof that.oldExtent === "undefined") {
@@ -1589,23 +1608,32 @@
//
this.initializeWms();
+ if (typeof wms !== "object" || wms.length === 0) {
+ var errorMsg = "There are no WMS in map '" + this.elementName + "'";
+ new Mapbender.Exception(errorMsg);
+ $(domElement).css({
+ "border": "1px solid red",
+ "color": "red"
+ }).text(errorMsg);
+ }
+ else {
+ for (var i = 0; i < wms[0].gui_epsg.length; i++) {
+ if (wms[0].gui_wms_epsg == wms[0].gui_epsg[i]) {
+ bbox_minx = parseFloat(wms[0].gui_minx[i]);
+ bbox_miny = parseFloat(wms[0].gui_miny[i]);
+ bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
+ bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
+ break;
+ }
+ }
+
+ this.setSrs({
+ srs: wms[0].gui_wms_epsg,
+ extent: new Mapbender.Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy)
+ });
+ }
- for (var i = 0; i < wms[0].gui_epsg.length; i++) {
- if (wms[0].gui_wms_epsg == wms[0].gui_epsg[i]) {
- bbox_minx = parseFloat(wms[0].gui_minx[i]);
- bbox_miny = parseFloat(wms[0].gui_miny[i]);
- bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
- bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
- break;
- }
- }
- this.setSrs({
- srs: wms[0].gui_wms_epsg,
- extent: new Mapbender.Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy)
- });
-
-
this.afterMapRequest = new Mapbender.Event();
this.events = {
afterMapRequest: this.afterMapRequest,
Modified: trunk/mapbender/http/javascripts/mod_dragMapSize.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_dragMapSize.php 2010-07-04 10:24:00 UTC (rev 6558)
+++ trunk/mapbender/http/javascripts/mod_dragMapSize.php 2010-07-04 10:32:43 UTC (rev 6559)
@@ -119,7 +119,10 @@
targetObject.setWidth(targetObject.getWidth() + parseFloat(dif_x));
targetObject.setHeight(targetObject.getHeight() + parseFloat(dif_y));
- var mybbox = targetObject.extent.toString().split(",");
+ var mybbox = targetObject.getExtent().split(",");
+ if (typeof mybbox !== "object" || mybbox.length !== 4) {
+ return;
+ }
targetObject.setExtent(mybbox[0], pos[1], pos[0], mybbox[3]);
targetObject.setMapRequest();
eventResizeMap.trigger();
Modified: trunk/mapbender/http/plugins/mb_overview.js
===================================================================
--- trunk/mapbender/http/plugins/mb_overview.js 2010-07-04 10:24:00 UTC (rev 6558)
+++ trunk/mapbender/http/plugins/mb_overview.js 2010-07-04 10:32:43 UTC (rev 6559)
@@ -83,10 +83,7 @@
map = Mapbender.modules[options.id];
map.isOverview = true;
- // if the setBackground module is active,
- // the overview wms might be hidden.
- // so we activate it here.
- map.wms[0].gui_wms_visible = 1;
+
map.skipWmsIfSrsNotSupported =
options.skipWmsIfSrsNotSupported === 1 ? true : false;
@@ -126,6 +123,15 @@
});
return false;
});
+
+ // if the setBackground module is active,
+ // the overview wms might be hidden.
+ // so we activate it here.
+ var ovWmsArray = map.wms;
+ if (typeof ovWmsArray !== "object" || ovWmsArray.length === 0) {
+ return;
+ }
+ ovWmsArray[0].gui_wms_visible = 1;
});
//
More information about the Mapbender_commits
mailing list