moved oppositeQuadrant() function from Anchored.js to Util.js, where it is now a static function on the OpenLayers.Bounds class. Updated usage in code accordingly. Added test.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@343 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -61,7 +61,7 @@ OpenLayers.Popup.Anchored.prototype =
|
|||||||
var extent = this.map.getExtent();
|
var extent = this.map.getExtent();
|
||||||
var quadrant = extent.determineQuadrant(lonlat);
|
var quadrant = extent.determineQuadrant(lonlat);
|
||||||
|
|
||||||
return this.oppositeQuadrant(quadrant);
|
return OpenLayers.Bounds.oppositeQuadrant(quadrant);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,24 +97,5 @@ OpenLayers.Popup.Anchored.prototype =
|
|||||||
return newPx;
|
return newPx;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*
|
|
||||||
* @param {String} quadrant
|
|
||||||
*
|
|
||||||
* @returns The opposing quadrant ("br" "tr" "tl" "bl"). For Example, if
|
|
||||||
* you pass in "bl" it returns "tr", if you pass in "br" it
|
|
||||||
* returns "tl", etc.
|
|
||||||
* @type String
|
|
||||||
*/
|
|
||||||
oppositeQuadrant: function(quadrant) {
|
|
||||||
var opp = "";
|
|
||||||
|
|
||||||
opp += (quadrant.charAt(0) == 't') ? 'b' : 't';
|
|
||||||
opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l';
|
|
||||||
|
|
||||||
return opp;
|
|
||||||
},
|
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Popup.Anchored"
|
CLASS_NAME: "OpenLayers.Popup.Anchored"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -454,6 +454,22 @@ OpenLayers.Bounds.fromString = function(str) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {String} quadrant
|
||||||
|
*
|
||||||
|
* @returns The opposing quadrant ("br" "tr" "tl" "bl"). For Example, if
|
||||||
|
* you pass in "bl" it returns "tr", if you pass in "br" it
|
||||||
|
* returns "tl", etc.
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
OpenLayers.Bounds.oppositeQuadrant = function(quadrant) {
|
||||||
|
var opp = "";
|
||||||
|
|
||||||
|
opp += (quadrant.charAt(0) == 't') ? 'b' : 't';
|
||||||
|
opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l';
|
||||||
|
|
||||||
|
return opp;
|
||||||
|
};
|
||||||
|
|
||||||
// Some other helpful things
|
// Some other helpful things
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,15 @@
|
|||||||
t.eq( bounds.determineQuadrant(br), "br", "bounds.determineQuadrant correctly identifies a coordinate in the bottom right quadrant");
|
t.eq( bounds.determineQuadrant(br), "br", "bounds.determineQuadrant correctly identifies a coordinate in the bottom right quadrant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_10_Bounds_oppositeQuadrant(t) {
|
||||||
|
|
||||||
|
t.plan( 4 );
|
||||||
|
|
||||||
|
t.eq( OpenLayers.Bounds.oppositeQuadrant("tl"), "br", "OpenLayers.Bounds.oppositeQuadrant returns 'br' for 'tl'");
|
||||||
|
t.eq( OpenLayers.Bounds.oppositeQuadrant("tr"), "bl", "OpenLayers.Bounds.oppositeQuadrant returns 'bl' for 'tr'");
|
||||||
|
t.eq( OpenLayers.Bounds.oppositeQuadrant("bl"), "tr", "OpenLayers.Bounds.oppositeQuadrant returns 'tr' for 'bl'");
|
||||||
|
t.eq( OpenLayers.Bounds.oppositeQuadrant("br"), "tl", "OpenLayers.Bounds.oppositeQuadrant returns 'tl' for 'br'");
|
||||||
|
}
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user