[OpenLayers-Trac] [OpenLayers] #1121: implement calculateBounds for Polygon.js
OpenLayers
trac at openlayers.org
Thu Nov 1 10:56:48 EDT 2007
#1121: implement calculateBounds for Polygon.js
------------------------------+---------------------------------------------
Reporter: bartvde | Owner: tschaub
Type: task | Status: new
Priority: minor | Milestone:
Component: Geometry.Polygon | Version: 2.5
Keywords: |
------------------------------+---------------------------------------------
The following is an example implementation:
/**
* APIMethod: calculateBounds
* Recalculate the bounds for the polygon.
*/
calculateBounds: function() {
if ( this.components && (this.components.length > 0)) {
var minx = Infinity;
var maxx = -Infinity;
var miny = Infinity;
var maxy = -Infinity;
for(var i=0; i<this.components[0].components.length; i++) {
var x = this.components[0].components[i].x;
minx = Math.min(minx, x);
maxx = Math.max(maxx, x);
var y = this.components[0].components[i].y;
miny = Math.min(miny, y);
maxy = Math.max(maxy, y);
}
return new OpenLayers.Bounds(minx, miny, maxx, maxy);
}
},
--
Ticket URL: <http://trac.openlayers.org/ticket/1121>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list