ol-cesium icon indicating copy to clipboard operation
ol-cesium copied to clipboard

Features are not picked when in 3D mode

Open jmgomezpoveda opened this issue 9 years ago • 8 comments

Using a Vector/KML layer in OpenLayers 3. When using ol3-cesium in 3D mode this is somewhat working.

However, the map "pointermove" and "click" events are not triggered when placing the mouse over the feature or clicking on it.

jmgomezpoveda avatar Apr 11 '16 11:04 jmgomezpoveda

The 2D OL3 interactions are not made available in 3D.

OL3 ol.source.Cluster source is not adapted to the tilted views or 3D. You may try to trigger change events on the cluster source to force redraws or have a look to https://github.com/gberaudo/ol3-cluster-tool.

Text defined in the style of items in the vector layer is not correctly rendered. What do you mean? Do you have an example?

gberaudo avatar Apr 11 '16 11:04 gberaudo

Text defined in the style of items in the vector layer is not correctly rendered. What do you mean? Do you have an example?

Sorry, that was elaborated separately in https://github.com/openlayers/ol3-cesium/issues/345 -I have removed it from the issue description.

jmgomezpoveda avatar Apr 11 '16 11:04 jmgomezpoveda

I am not sure what has happened with the description, as the cluster discussion was meant to be only in https://github.com/openlayers/ol3-cesium/issues/346. I have just updated the issue description.

jmgomezpoveda avatar Apr 11 '16 12:04 jmgomezpoveda

The 2D OL3 interactions are not made available in 3D.

So, is this something that can be supported in some other way on the application side, or something that could be in the roadmap for ol3-cesium?

jmgomezpoveda avatar Apr 11 '16 12:04 jmgomezpoveda

The application can of course set a listener in Cesium and react to pointer move or click. Then check what OL3 features are under the cursor and react accordingly.

We could also imagine OL3-Cesium doing this automatically. Maybe this could be experimented with the OL3 select interaction.

gberaudo avatar Apr 11 '16 12:04 gberaudo

Actually, I just checked that the click event is triggered when I click on the 3D map. What really happens is that when the click event came with the 3D map enabled, map.forEachFeatureAtPixel does not return anything.

jmgomezpoveda avatar Apr 24 '16 20:04 jmgomezpoveda

So, I have workarounded the events issue replacing the calls to map.forEachFeatureAtPixel with the following function (from both "pointermove" and "click" events):

getFeaturesAtPixel: function(pixel) {
    var features = [];
    if (this.map3d && this.map3d.getEnabled()) {
        var pickedObject = this.map3d.getCesiumScene().pick(new Cesium.Cartesian2(pixel[0], pixel[1]));
        if (typeof pickedObject !== "undefined") {
            features.push(pickedObject.primitive.olFeature);
        }
    } else {
        this.map.forEachFeatureAtPixel(pixel, function(feature) {
            features.push(feature);
        });
    }

    return features;
}

In a nutshell, this check whether we are in Cesium or OpenLayers rendering mode, and uses scene.pick or map.forEachFeatureAtPixel depending on the case.

Could an adapted version of this be of use to ol3-cesium?

jmgomezpoveda avatar Apr 25 '16 02:04 jmgomezpoveda

Would be an interesting experimentation for OL3-Cesium. In the OL3-Cesium constructor, the ol.map.prototype.forEachFeatureAtPixel function could be replaced by an adapted version of your code. This behaviour should be opt-in.

gberaudo avatar Apr 25 '16 07:04 gberaudo