[fusion-commits] r2466 - trunk/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Nov 22 00:38:00 EST 2011


Author: liuar
Date: 2011-11-21 21:38:00 -0800 (Mon, 21 Nov 2011)
New Revision: 2466

Modified:
   trunk/lib/Map.js
Log:
on behalf of yangte
http://trac.osgeo.org/fusion/ticket/492
If a point feature is set as the selection then the map zooms to a scale of 1:1. The map should not zoom so far to a point feature. It would be rarely that 1:1 is useful for a GIS user.

Steps to reproduce:
1. Create a layer based on a point feature and add it to a map
2. View the map in fusion web layout
3. Use the ?\226?\128?\152Query?\226?\128?\153 widget to find one of the features on the point layer
4. Select one of the found features in the Results list and then click the ?\226?\128?\152Select?\226?\128?\153 button
5. Map is zoomed to 1:1[[BR]] 6. Same thing happens when the setSelection javascript function is called.
7. Same thing happens if a point feature is manually selected and then ?\226?\128?\152Zoom Selection?\226?\128?\153 is used
8. Same thing happens when choosing a result from the ?\226?\128?\152Search?\226?\128?\153 widget
all these functions will call the js function "setExtents" in Map.js, when the parameter "oExtents" is a point which should be a rectangle, it will zoom to 1:1, to prevent this situation, I suggest to add a check like this: 

if(oExtents.bottom == oExtents.top && oExtents.left == oExtents.right)
{
    this.oMapOL.panTo(new OpenLayers.LonLat(oExtents.left, oExtents.top));
}

Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js	2011-11-22 02:54:26 UTC (rev 2465)
+++ trunk/lib/Map.js	2011-11-22 05:38:00 UTC (rev 2466)
@@ -283,7 +283,7 @@
 
         this.mapGroup = mapGroup;
         var startIndex = loadOverlays?1:0;
-        for (var i = this.aMaps.length-1; i >= startIndex; i--) {
+        for (var i=startIndex; i<this.aMaps.length; i++) {
           if (this.aMaps[i].oLayerOL) {
             this.aMaps[i].oLayerOL.destroy();
             this.aMaps.splice(i,1);
@@ -635,7 +635,7 @@
          for (var i=0; i<this.aMaps.length; i++ ) {
            if (!this.aMaps[i].supports.query) 
          // if(this.aMaps[i].layerType == "Google" || this.aMaps[i].layerType == "Yahoo" ||this.aMaps[i].layerType == "VirtualEarth" )
-			     continue;
+               continue;
              this.nSelectionMaps++;
              this.aMaps[i].getSelection(
                     OpenLayers.Function.bind(this.accumulateSelection, this, this.aMaps[i]),
@@ -861,8 +861,20 @@
           if (this.aMaps[i].oLayerOL.params && this.aMaps[i].noCache) {
             this.aMaps[i].oLayerOL.params.ts = (new Date()).getTime();
           }
+      }
+        
+        // when the parameter "oExtents" is a point which should be a rectangle, it will zoom to 1:1
+        // this is often because the selected feature is a point feature, like tree
+        // in this situation we can pan the point to the center, no need to zoom to 1:1
+        if(oExtents.bottom == oExtents.top && oExtents.left == oExtents.right)
+        {
+            this.oMapOL.panTo(new OpenLayers.LonLat(oExtents.left, oExtents.top));
         }
-        this.oMapOL.zoomToExtent(oExtents,true);
+        else
+        {
+            this.oMapOL.zoomToExtent(oExtents,true);
+        }
+        
         this._oCurrentExtents = this.oMapOL.getExtent();
     },
 



More information about the fusion-commits mailing list