Merge pull request #2114 from tsauerwein/draw-and-modify
Add example combining draw and modify interaction
This commit is contained in:
@@ -67,6 +67,7 @@ ol.events.condition.never = goog.functions.FALSE;
|
||||
/**
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} True if the event is a `singleclick` event.
|
||||
* @todo api
|
||||
*/
|
||||
ol.events.condition.singleClick = function(mapBrowserEvent) {
|
||||
return mapBrowserEvent.type == ol.MapBrowserEvent.EventType.SINGLECLICK;
|
||||
@@ -134,6 +135,7 @@ ol.events.condition.targetNotEditable = function(mapBrowserEvent) {
|
||||
/**
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} True if the event originates from a mouse device.
|
||||
* @todo api
|
||||
*/
|
||||
ol.events.condition.mouseOnly = function(mapBrowserEvent) {
|
||||
goog.asserts.assertInstanceof(mapBrowserEvent, ol.MapBrowserPointerEvent);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user