diff --git a/package.json b/package.json
index 8d7d5d5..256c864 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"jquery": "3.1.0",
"lodash": "4.14.1",
"notifyjs-browser": "0.4.2",
- "openlayers": "github:KlausBenndorf/ol3#g4u3_3.16",
+ "openlayers": "github:KlausBenndorf/ol3#g4u3_3.17.1",
"proj4": "2.3.14",
"strip-json-comments": "2.0.1"
},
diff --git a/src/FeaturePopup.js b/src/FeaturePopup.js
index b1efef0..fdebbdf 100644
--- a/src/FeaturePopup.js
+++ b/src/FeaturePopup.js
@@ -162,6 +162,15 @@ export default class FeaturePopup extends ol.Object {
this.map__ = null
}
+ /**
+ * @param {ol.Feature} feature
+ * @returns {boolean}
+ * @private
+ */
+ static filter_ (feature) {
+ return !feature.get('disabled') && (feature.get('name') || feature.get('description'))
+ }
+
/**
* @param {G4UMap} map
*/
@@ -239,12 +248,10 @@ export default class FeaturePopup extends ol.Object {
this.$element_.append(this.window_.get$Element())
- let filter = f => f.get('name') || f.get('description')
-
// feature click
map.getDefaultInteractions('singleClick')[ 0 ].on('select', e => {
- let selected = e.selected.filter(filter)
+ let selected = e.selected.filter(FeaturePopup.filter_)
if (selected.length) {
this.onFeatureClick_(selected[ 0 ])
e.target.getFeatures().remove(selected[ 0 ]) // remove feature to be able to select feature again
@@ -255,8 +262,8 @@ export default class FeaturePopup extends ol.Object {
// feature hover
map.getDefaultInteractions('mouseMove')[ 0 ].on('select', e => {
- let selected = e.selected.filter(filter)
- let deselected = e.deselected.filter(filter)
+ let selected = e.selected.filter(FeaturePopup.filter_)
+ let deselected = e.deselected.filter(FeaturePopup.filter_)
if (selected.length) {
$(map.getViewport()).addClass(cssClasses.clickable)
} else if (deselected.length) {
diff --git a/src/FeatureTooltip.js b/src/FeatureTooltip.js
index ded5bf1..758955a 100644
--- a/src/FeatureTooltip.js
+++ b/src/FeatureTooltip.js
@@ -52,6 +52,10 @@ export default class FeatureTooltip {
this.$element_.parent().addClass(this.className_ + '-container')
}
+ static filter_ (feature) {
+ return !feature.get('disabled') && feature.get('name')
+ }
+
/**
* @param {G4UMap} map
*/
@@ -63,10 +67,9 @@ export default class FeatureTooltip {
if (map) {
map.addOverlay(this.overlay_)
- let filter = f => f.get('name')
let interaction = map.getDefaultInteractions('mouseMove')[0]
interaction.on('select', e => {
- let selected = e.selected.filter(filter)
+ let selected = e.selected.filter(FeatureTooltip.filter_)
if (selected.length) {
this.setFeature(selected[0])
} else {
diff --git a/src/G4UMap.js b/src/G4UMap.js
index bc79beb..560dc5e 100644
--- a/src/G4UMap.js
+++ b/src/G4UMap.js
@@ -495,7 +495,7 @@ export default class G4UMap extends ol.Map {
* @param {GroupLayer} groupLayer
*/
setLayerGroup (groupLayer) {
- groupLayer.setMap(this)
+ groupLayer.provideMap(this)
super.setLayerGroup(groupLayer)
}
diff --git a/src/Styling.js b/src/Styling.js
index ae469ac..b9419dc 100644
--- a/src/Styling.js
+++ b/src/Styling.js
@@ -345,9 +345,6 @@ export default class Styling {
stylePrimitive = curStyles[0]
}
}
- if (this.get('opacity')) {
- stylePrimitive = thisRef.adjustColorOpacity(thisRef.cloneStyle(stylePrimitive), this.get('opacity'))
- }
return [stylePrimitive]
}
diff --git a/src/configurators/LayerConfigurator.js b/src/configurators/LayerConfigurator.js
index d4848f8..a7242ee 100644
--- a/src/configurators/LayerConfigurator.js
+++ b/src/configurators/LayerConfigurator.js
@@ -1,6 +1,6 @@
import ol from 'openlayers'
-import GroupLayer from '../layers/GroupLayer'
+import {GroupLayer} from '../layers/GroupLayer'
import { copyDeep } from '../utilitiesObject'
import { checkFor } from '../utilities'
import Debug from '../Debug'
diff --git a/src/configurators/LayerFactory.js b/src/configurators/LayerFactory.js
index c59cb3b..d18cc17 100644
--- a/src/configurators/LayerFactory.js
+++ b/src/configurators/LayerFactory.js
@@ -2,9 +2,9 @@ import ol from 'openlayers'
import {BaseLayerImage, ImageLayer} from '../layers/ImageLayer'
import {EmptyBaseLayer} from '../layers/EmptyBaseLayer'
-import BaseLayerTile from '../layers/BaseLayerTile'
-import GroupLayer from '../layers/GroupLayer'
-import VectorLayer from '../layers/VectorLayer'
+import {BaseLayerTile} from '../layers/BaseLayerTile'
+import {GroupLayer} from '../layers/GroupLayer'
+import {VectorLayer} from '../layers/VectorLayer'
import SourceServerVector from '../sources/SourceServerVector'
import QuerySource from '../sources/QuerySource'
import { copyDeep, take } from '../utilitiesObject'
diff --git a/src/configurators/UIConfigurator.js b/src/configurators/UIConfigurator.js
index e2eecbc..1b5f4f7 100644
--- a/src/configurators/UIConfigurator.js
+++ b/src/configurators/UIConfigurator.js
@@ -440,7 +440,7 @@ export default class UIConfigurator {
}
this.map_.addDefaultInteraction('singleClick', new FeatureSelect({
- condition: ol.events.condition.singleClick,
+ condition: e => ol.events.condition.singleClick(e) && $(e.originalEvent.target).is('canvas'),
style: null,
multi: true
}))
diff --git a/src/controls/GeoLocationButton.js b/src/controls/GeoLocationButton.js
index d04edb1..521498a 100644
--- a/src/controls/GeoLocationButton.js
+++ b/src/controls/GeoLocationButton.js
@@ -3,7 +3,7 @@ import $ from 'jquery'
import Control from './Control'
import { addTooltip } from '../html/html'
-import VectorLayer from '../layers/VectorLayer'
+import {VectorLayer} from '../layers/VectorLayer'
import MessageDisplay from '../MessageDisplay'
import {cssClasses} from '../globals'
diff --git a/src/controls/LayerSelector.js b/src/controls/LayerSelector.js
index 73f1b89..6f78cbf 100644
--- a/src/controls/LayerSelector.js
+++ b/src/controls/LayerSelector.js
@@ -1,6 +1,6 @@
import $ from 'jquery'
-import GroupLayer from '../layers/GroupLayer'
+import {GroupLayer} from '../layers/GroupLayer'
import ButtonBox from '../html/ButtonBox'
import Control from './Control'
import { offset } from '../utilities'
diff --git a/src/controls/MeasurementButton.js b/src/controls/MeasurementButton.js
index 4716455..ac1737a 100644
--- a/src/controls/MeasurementButton.js
+++ b/src/controls/MeasurementButton.js
@@ -3,7 +3,7 @@ import $ from 'jquery'
import Control from './Control'
import { cssClasses, keyCodes } from '../globals'
-import VectorLayer from '../layers/VectorLayer'
+import {VectorLayer} from '../layers/VectorLayer'
import '../../less/measurement.less'
diff --git a/src/html/Window.js b/src/html/Window.js
index 92c3692..acbee95 100644
--- a/src/html/Window.js
+++ b/src/html/Window.js
@@ -53,6 +53,7 @@ export default class Window extends ol.Object {
* @private
*/
this.$element_ = $('
').addClass(this.className_)
+ .on('click', e => e.stopPropagation())
/**
* @type {jQuery}
diff --git a/src/layers/BaseLayerMixin.js b/src/layers/BaseLayerMixin.js
index f941589..13a2626 100644
--- a/src/layers/BaseLayerMixin.js
+++ b/src/layers/BaseLayerMixin.js
@@ -1,4 +1,4 @@
-import GroupLayer from './GroupLayer'
+import {GroupLayer} from './GroupLayer'
/**
* @typedef {object} BaseLayerMixinOptions
@@ -8,7 +8,7 @@ import GroupLayer from './GroupLayer'
/**
* This mixin provides baselayer functionality to any layer
*/
-export default class BaseLayerMixin {
+export class BaseLayerMixin {
/**
* @param {BaseLayerMixinOptions} options
*/
diff --git a/src/layers/BaseLayerTile.js b/src/layers/BaseLayerTile.js
index 091c692..00c2347 100644
--- a/src/layers/BaseLayerTile.js
+++ b/src/layers/BaseLayerTile.js
@@ -1,29 +1,9 @@
import ol from 'openlayers'
-import BaseLayerMixin from './BaseLayerMixin'
-import LayerLoadProcessCountMixin from './LayerLoadProcessCountMixin'
+import {BaseLayerMixin} from './BaseLayerMixin'
+import {LayerLoadProcessCountMixin} from './LayerLoadProcessCountMixin'
import { mixin } from '../utilities'
+import {ProvideMapMixin} from './ProvideMapMixin'
-export default class BaseLayerTile extends mixin(mixin(ol.layer.Tile, BaseLayerMixin), LayerLoadProcessCountMixin) {
- /**
- * @param {G4UMap} map
- */
- setMap (map) {
- /**
- * WORKAROUND
- * As openlayers identifies managed layers (i.e. layers that are registered via the maps addLayer function)
- * by the fact that the setMap method was called and we need a reference to the map in layers contained in a
- * grouplayer, we overwrite the setMap method to still have access to the map via the normal way
- * @type {G4UMap}
- * @private
- */
- this.map__ = map
- }
-
- /**
- * @returns {G4UMap}
- */
- getMap () {
- return this.map__
- }
-}
+export const BaseLayerTile =
+ mixin(mixin(mixin(ol.layer.Tile, ProvideMapMixin), BaseLayerMixin), LayerLoadProcessCountMixin)
diff --git a/src/layers/EmptyBaseLayer.js b/src/layers/EmptyBaseLayer.js
index 2457568..79bebbc 100644
--- a/src/layers/EmptyBaseLayer.js
+++ b/src/layers/EmptyBaseLayer.js
@@ -13,26 +13,4 @@ export class EmptyBaseLayer extends BaseLayerImage {
})
super(options)
}
-
- /**
- * @param {G4UMap} map
- */
- setMap (map) {
- /**
- * WORKAROUND
- * As openlayers identifies managed layers (i.e. layers that are registered via the maps addLayer function)
- * by the fact that the setMap method was called and we need a reference to the map in layers contained in a
- * grouplayer, we overwrite the setMap method to still have access to the map via the normal way
- * @type {G4UMap}
- * @private
- */
- this.map__ = map
- }
-
- /**
- * @returns {G4UMap}
- */
- getMap () {
- return this.map__
- }
}
diff --git a/src/layers/GroupLayer.js b/src/layers/GroupLayer.js
index 0307b18..70551b8 100644
--- a/src/layers/GroupLayer.js
+++ b/src/layers/GroupLayer.js
@@ -1,10 +1,12 @@
import ol from 'openlayers'
+import {ProvideMapMixin} from './ProvideMapMixin'
+import {mixin} from '../utilities'
/**
* This Class is a Wrap around {ol.layer.Group} providing some extra functionality. This class is normally used for a
* category of layers containing them.
*/
-export default class GroupLayer extends ol.layer.Group {
+export class GroupLayer extends mixin(ol.layer.Group, ProvideMapMixin) {
/**
* @param {object} [options={}]
*/
@@ -13,42 +15,31 @@ export default class GroupLayer extends ol.layer.Group {
this.getLayers().on('add', /** ol.CollectionEvent */ e => {
let layer = e.element
- if (layer.setMap) {
- layer.setMap(this.getMap())
+ if (layer.provideMap) {
+ layer.provideMap(this.getProvidedMap())
}
})
this.getLayers().on('remove', /** ol.CollectionEvent */ e => {
let layer = e.element
- if (layer.setMap) {
- layer.setMap(null)
+ if (layer.provideMap) {
+ layer.provideMap(null)
}
})
}
/**
- * The setMap methods of all contained children are called recursively
+ * The provideMap methods of all contained children are called recursively
* @param {G4UMap} map
*/
- setMap (map) {
- /**
- * @type {G4UMap}
- * @private
- */
- this.map_ = map
+ provideMap (map) {
+ super.provideMap(map)
this.getLayers().forEach(layer => {
- layer.setMap(map)
+ if (layer.provideMap) { layer.provideMap(map) }
})
}
- /**
- * @returns {G4UMap}
- */
- getMap () {
- return this.map_
- }
-
/**
* calls callback for every terminal, non-group Layer
* @param {Function} callback
diff --git a/src/layers/ImageLayer.js b/src/layers/ImageLayer.js
index 1795bb6..9fad27d 100644
--- a/src/layers/ImageLayer.js
+++ b/src/layers/ImageLayer.js
@@ -1,34 +1,10 @@
import ol from 'openlayers'
-import LayerLoadProcessCountMixin from './LayerLoadProcessCountMixin'
-import BaseLayerMixin from './BaseLayerMixin'
+import {LayerLoadProcessCountMixin} from './LayerLoadProcessCountMixin'
+import {BaseLayerMixin} from './BaseLayerMixin'
import { mixin } from '../utilities'
+import {ProvideMapMixin} from './ProvideMapMixin'
-export class ImageLayer extends mixin(ol.layer.Image, LayerLoadProcessCountMixin) {
- /**
- * @param {G4UMap} map
- */
- setMap (map) {
- /**
- * WORKAROUND
- * As openlayers identifies managed layers (i.e. layers that are registered via the maps addLayer function)
- * by the fact that the setMap method was called and we need a reference to the map in layers contained in a
- * grouplayer, we overwrite the setMap method to still have access to the map via the normal way
- * @type {G4UMap}
- * @private
- */
- this.map__ = map
- }
-
- /**
- * @returns {G4UMap}
- */
- getMap () {
- return this.map__
- }
-}
-
-export class BaseLayerImage extends mixin(ImageLayer, BaseLayerMixin) {
-
-}
+export const ImageLayer = mixin(mixin(ol.layer.Image, ProvideMapMixin), LayerLoadProcessCountMixin)
+export const BaseLayerImage = mixin(ImageLayer, BaseLayerMixin)
diff --git a/src/layers/LayerLoadProcessCountMixin.js b/src/layers/LayerLoadProcessCountMixin.js
index c595264..2dcec1a 100644
--- a/src/layers/LayerLoadProcessCountMixin.js
+++ b/src/layers/LayerLoadProcessCountMixin.js
@@ -1,7 +1,7 @@
/**
* A mixin to keep track the amount of load processes a source is currently waiting for
*/
-export default class LayerLoadProcessCountMixin {
+export class LayerLoadProcessCountMixin {
initialize () {
/**
* @type {number}
diff --git a/src/layers/ProvideMapMixin.js b/src/layers/ProvideMapMixin.js
new file mode 100644
index 0000000..3111164
--- /dev/null
+++ b/src/layers/ProvideMapMixin.js
@@ -0,0 +1,19 @@
+export class ProvideMapMixin {
+ /**
+ * @param {G4UMap} map
+ */
+ provideMap (map) {
+ /**
+ * @type {G4UMap|undefined}
+ * @private
+ */
+ this.providedMap_ = map
+ }
+
+ /**
+ * @returns {G4UMap|undefined}
+ */
+ getProvidedMap () {
+ return this.providedMap_
+ }
+}
diff --git a/src/layers/VectorLayer.js b/src/layers/VectorLayer.js
index ad1fc32..a6dbfa6 100644
--- a/src/layers/VectorLayer.js
+++ b/src/layers/VectorLayer.js
@@ -1,14 +1,15 @@
import ol from 'openlayers'
-import LayerLoadProcessCountMixin from './LayerLoadProcessCountMixin'
+import {LayerLoadProcessCountMixin} from './LayerLoadProcessCountMixin'
import { mixin } from '../utilities'
+import {ProvideMapMixin} from './ProvideMapMixin'
/**
* @typedef {object} VectorLayerOptions
* @property {string[]} [mutators=[]] list of mutators (changes featurepopup content) to use for this layer.
*/
-export default class VectorLayer extends mixin(ol.layer.Vector, LayerLoadProcessCountMixin) {
+export class VectorLayer extends mixin(mixin(ol.layer.Vector, ProvideMapMixin), LayerLoadProcessCountMixin) {
constructor (options = {}) {
super(options)
@@ -21,26 +22,4 @@ export default class VectorLayer extends mixin(ol.layer.Vector, LayerLoadProcess
// saving text mutators
this.set('mutators', options.mutators || [])
}
-
- /**
- * @param {G4UMap} map
- */
- setMap (map) {
- /**
- * WORKAROUND
- * As openlayers identifies managed layers (i.e. layers that are registered via the maps addLayer function)
- * by the fact that the setMap method was called and we need a reference to the map in layers contained in a
- * grouplayer, we overwrite the setMap method to still have access to the map via the normal way
- * @type {G4UMap}
- * @private
- */
- this.map__ = map
- }
-
- /**
- * @returns {G4UMap}
- */
- getMap () {
- return this.map__
- }
}
diff --git a/tests/selenium/config.js b/tests/selenium/config.js
index 0153f71..ca691bb 100644
--- a/tests/selenium/config.js
+++ b/tests/selenium/config.js
@@ -1,5 +1,5 @@
export default {
- mochaTimeout: 10000,
+ mochaTimeout: 5000,
seleniumTimeout: 5000,
testClient: 'http://localhost:8080'
}
diff --git a/tests/selenium/featuretooltip_spec.js b/tests/selenium/featuretooltip_spec.js
index d2a480b..7e145a3 100644
--- a/tests/selenium/featuretooltip_spec.js
+++ b/tests/selenium/featuretooltip_spec.js
@@ -64,10 +64,10 @@ function addLayerWithPolygonAroundMapCenter (name, description, edgeLength) {
}
test.describe('FeatureTooltip', function () {
+ this.timeout(config.mochaTimeout)
let driver
test.before(function () {
- this.timeout(config.mochaTimeout)
driver = phantomDriver()
driver.manage().window().setSize(1200, 800)
driver.manage().timeouts().implicitlyWait(config.seleniumTimeout)
@@ -85,7 +85,8 @@ test.describe('FeatureTooltip', function () {
.mouseMove(driver.findElement(By.className('ol-viewport')))
.perform()
.then(function () {
- assert(driver.findElement(By.className('g4u-featuretooltip'), 'Tooltip should not be visible').isDisplayed()).equalTo(false)
+ assert(driver.findElement(By.className('g4u-featuretooltip'),
+ 'Tooltip should not be visible').isDisplayed()).equalTo(false)
done()
})
})
@@ -185,6 +186,7 @@ test.describe('FeatureTooltip', function () {
waitUntilMapReady(driver).then(() => {
return driver.executeScript(stringifyFunctionCall(addLayerWithPointAtMapCenter, 'namePoint', 'description'))
}).then(() => {
+ console.log('map ready')
return driver.executeScript(
stringifyFunctionCall(addLayerWithPolygonAroundMapCenter, 'namePolygon', 'description', 1000))
}).then(() => {