@@ -412,6 +412,34 @@ goog.require('olcs.core.OlLayerPrimitive');
412
412
} ;
413
413
414
414
415
+ /**
416
+ * Synchronizes the vector layer rendering properties (currently only
417
+ * 'visible' and 'opacity') to the given Cesium primitives.
418
+ * @param {!ol.layer.Vector } olLayer
419
+ * @param {!Cesium.PrimitiveCollection } csPrimitives
420
+ * @api
421
+ */
422
+ olcs . core . updateCesiumPrimitives = function ( olLayer , csPrimitives ) {
423
+ var visible = olLayer . getVisible ( ) ;
424
+ if ( goog . isDef ( visible ) ) {
425
+ csPrimitives . show = visible ;
426
+ }
427
+ //FIXME Make this work for all geometry types, not just points
428
+ var bbs = csPrimitives . context . billboards ;
429
+ var opacity = olLayer . getOpacity ( ) ;
430
+ if ( ! goog . isDef ( opacity ) ) {
431
+ opacity = 1 ;
432
+ }
433
+ bbs . olLayerOpacity = opacity ;
434
+ var i , bb ;
435
+ for ( i = bbs . length - 1 ; i >= 0 ; -- i ) {
436
+ bb = bbs . get ( i ) ;
437
+ //FIXME Use Cesium.Color.fromAlpha after the next Cesium update
438
+ bb . color = new Cesium . Color ( 1.0 , 1.0 , 1.0 , bb . olStyleOpacity * opacity ) ;
439
+ }
440
+ } ;
441
+
442
+
415
443
/**
416
444
* Convert a 2D or 3D OpenLayers coordinate to Cesium.
417
445
* @param {ol.Coordinate } coordinate Ol3 coordinate.
@@ -789,16 +817,20 @@ goog.require('olcs.core.OlLayerPrimitive');
789
817
var position = olcs . core . ol4326CoordinateToCesiumCartesian ( center ) ;
790
818
var color ;
791
819
var opacity = imageStyle . getOpacity ( ) ;
792
- if ( goog . isDef ( opacity ) ) {
793
- color = new Cesium . Color ( 1.0 , 1.0 , 1.0 , opacity ) ;
820
+ if ( ! goog . isDef ( opacity ) ) {
821
+ opacity = 1 ;
794
822
}
823
+ //FIXME Use Cesium.Color.fromAlpha after the next Cesium update
824
+ color = new Cesium . Color ( 1.0 , 1.0 , 1.0 ,
825
+ opacity * billboards . olLayerOpacity ) ;
795
826
var bb = billboards . add ( {
796
827
// always update Cesium externs before adding a property
797
828
image : image ,
798
829
color : color ,
799
830
verticalOrigin : Cesium . VerticalOrigin . BOTTOM ,
800
831
position : position
801
832
} ) ;
833
+ bb . olStyleOpacity = opacity ;
802
834
if ( opt_newBillboardCallback ) {
803
835
opt_newBillboardCallback ( bb ) ;
804
836
}
0 commit comments