Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features are not picked when in 3D mode #344

Open
jmgomezpoveda opened this issue Apr 11, 2016 · 8 comments
Open

Features are not picked when in 3D mode #344

jmgomezpoveda opened this issue Apr 11, 2016 · 8 comments

Comments

@jmgomezpoveda
Copy link
Contributor

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.

@gberaudo
Copy link
Member

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?

@jmgomezpoveda
Copy link
Contributor Author

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 #345 -I have removed it from the issue description.

@jmgomezpoveda
Copy link
Contributor Author

I am not sure what has happened with the description, as the cluster discussion was meant to be only in #346. I have just updated the issue description.

@jmgomezpoveda
Copy link
Contributor Author

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?

@gberaudo
Copy link
Member

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.

@jmgomezpoveda
Copy link
Contributor Author

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
Copy link
Contributor Author

jmgomezpoveda commented Apr 25, 2016

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?

@gberaudo
Copy link
Member

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.

@jmgomezpoveda jmgomezpoveda changed the title Map events cannot be captured when in 3D mode Features are not picked when in 3D mode Apr 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants