Merge pull request #2114 from tsauerwein/draw-and-modify

Add example combining draw and modify interaction
This commit is contained in:
Éric Lemoine
2014-06-10 10:00:27 +02:00
6 changed files with 185 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ goog.require('ol.FeatureOverlay');
goog.require('ol.Map');
goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.events.condition');
goog.require('ol.feature');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
@@ -192,6 +193,13 @@ ol.interaction.Draw = function(options) {
*/
this.geometryName_ = options.geometryName;
/**
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = goog.isDef(options.condition) ?
options.condition : ol.events.condition.noModifierKeys;
};
goog.inherits(ol.interaction.Draw, ol.interaction.Pointer);
@@ -244,8 +252,12 @@ ol.interaction.Draw.prototype.handleMapBrowserEvent = function(event) {
* @return {boolean} Pass the event to other interactions.
*/
ol.interaction.Draw.prototype.handlePointerDown = function(event) {
this.downPx_ = event.pixel;
return true;
if (this.condition_(event)) {
this.downPx_ = event.pixel;
return true;
} else {
return false;
}
};