2

I went through the oL3- Cesium examples provided on their website. There was an example here which comprised of selecting the features in 2D view and the same will be reflected in the 3D one as well. But, when I went through the code, there was no interaction defined as such. They were extracting the feature present on the highlighted/ clicked coordinate,if any, and were applying styles.

What I mean to say is, there was no predefined interaction for selection thing, like it is in OL3 documentation here. So I wanted to ask are there actually no predefined interactions as of now, in this OL3-Cesium integration or am I missing out on something ? I primarily followed those examples provided on their website to understand the working.

Update :

In the example I provided above,they extracted the feature, if any, present at the clicked coordinate.That's reflected in 3D view as well. But when I try to add Ol3's select interaction in this :

var selectClick = new ol.interaction.Select({condition: ol.events.condition.click}); select = selectClick; if (select !== null) { map.addInteraction(select); select.on('select', function(e) { select.setStyle(selectionstyle); }); }

Features in 2D are being selected fine but it's not reflecting in the 3D view. So are these interactions not yet supported in Ol3-Cesium or I'm doing wrong?

5
  • The interaction is done via the lines: var ol3d = new olcs.OLCesium({map: map}); // map is the ol.Map instance ol3d.setEnabled(true); See the docs May 19, 2015 at 16:36
  • @JohnBarça : Aren't these lines handling the switching between 2D and 3D view? (And perhaps the synchronization between two).But when I try to add Ol3's select interaction in this : var selectClick = new ol.interaction.Select({ condition: ol.events.condition.click }); select = selectClick; if (select !== null) { map.addInteraction(select); select.on('select', function(e) { select.setStyle(selectionstyle); }); } Features in 2D are being selected fine but it's not reflecting in the 3D view. So are these interactions not yet supported in Ol3-Cesium or I'm doing wrong?
    – Ishan
    May 20, 2015 at 5:33
  • @JohnBarça : I'm sorry I'm trying to indent the code in comment but it's just not working .
    – Ishan
    May 20, 2015 at 5:38
  • Could you perhaps update the question with what you have put in the comments? May 20, 2015 at 5:43
  • @JohnBarça : yeah sure
    – Ishan
    May 20, 2015 at 5:45

1 Answer 1

2

If you look at the selection.js source of the example you linked, you will see these lines:

var ol3d = new olcs.OLCesium({map: map, target: 'map3d'});
var scene = ol3d.getCesiumScene();
ol3d.setEnabled(true);

This sets up the link between the OpenLayers map and the Caesium view, not the interaction control, which deals with events in the OpenLayers map view only. Here is the relevant Caesium source code. In that code, you will see that the linking is done via two further modules, RasterSynchronized and VectorSynchronizer.

The comments at the top of both of these files make it clear that the interaction is only from OpenLayers to Caesium, eg,

Unidirectionally synchronize OpenLayers vector layers to Cesium.

The ol.interaction.Select that comes later deals entirely with updating the styles on the OpenLayers map view, it is no way relates to the interaction with Caesium.

2
  • Ok. Thanks for telling me this. I was also thinking about adding interactions in Cesium view and wanted those changes to reflect in the geojson as well. Like if a polygon is there, I can modify that structure in Cesium view with the help of some Cesium interactions , like we can do with features in Ol3 . But keeping in view the information about the unidirectional synchronization you provided, I guess that won't be of any use as it won't be synchronized.
    – Ishan
    May 20, 2015 at 9:40
  • There is clearly two-way interaction in the example. I haven't figured out exactly where it is triggered, but it must be in the caesium code, not on the OL interaction side. May 21, 2015 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.