@@ -412,6 +412,34 @@ goog.require('olcs.core.OlLayerPrimitive');
412412 } ;
413413
414414
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+
415443 /**
416444 * Convert a 2D or 3D OpenLayers coordinate to Cesium.
417445 * @param {ol.Coordinate } coordinate Ol3 coordinate.
@@ -789,16 +817,20 @@ goog.require('olcs.core.OlLayerPrimitive');
789817 var position = olcs . core . ol4326CoordinateToCesiumCartesian ( center ) ;
790818 var color ;
791819 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 ;
794822 }
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 ) ;
795826 var bb = billboards . add ( {
796827 // always update Cesium externs before adding a property
797828 image : image ,
798829 color : color ,
799830 verticalOrigin : Cesium . VerticalOrigin . BOTTOM ,
800831 position : position
801832 } ) ;
833+ bb . olStyleOpacity = opacity ;
802834 if ( opt_newBillboardCallback ) {
803835 opt_newBillboardCallback ( bb ) ;
804836 }
0 commit comments