Add setCoordinates for linestring and dispatch change event

This commit is contained in:
Tim Schaub
2013-09-27 19:23:29 +02:00
parent e78690c2d2
commit 30b2e3930b
2 changed files with 46 additions and 1 deletions

View File

@@ -1,10 +1,12 @@
goog.provide('ol.geom.LineString');
goog.require('goog.asserts');
goog.require('goog.events.EventType');
goog.require('ol.CoordinateArray');
goog.require('ol.extent');
goog.require('ol.geom');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryEvent');
goog.require('ol.geom.GeometryType');
@@ -108,6 +110,19 @@ ol.geom.LineString.prototype.distanceFromCoordinate = function(coordinate) {
};
/**
* Update the linestring coordinates.
* @param {ol.CoordinateArray} coordinates Coordinates array.
*/
ol.geom.LineString.prototype.setCoordinates = function(coordinates) {
var oldBounds = this.bounds_;
this.bounds_ = null;
this.coordinates_ = coordinates;
this.dispatchEvent(new ol.geom.GeometryEvent(goog.events.EventType.CHANGE,
this, oldBounds));
};
/**
* @inheritDoc
*/
@@ -118,5 +133,5 @@ ol.geom.LineString.prototype.transform = function(transform) {
coord = coordinates[i];
transform(coord, coord, coord.length);
}
this.bounds_ = null;
this.setCoordinates(coordinates); // for change event
};