@@ -762,13 +762,13 @@ goog.require('olcs.core.OlLayerPrimitive');
762762 * @param {!ol.proj.ProjectionLike } projection
763763 * @param {!ol.style.Style } style
764764 * @param {!Cesium.BillboardCollection } billboards
765- * @param {number } featureId
766- * @param { Object.<number,!Cesium.Primitive|!Cesium.Billboard>= } opt_featureToCesiumMap
765+ * @param {function(!Cesium.Billboard)= } opt_newBillboardCallback Called when
766+ * the new billboard is added.
767767 * @return {Cesium.Primitive } primitives
768768 * @api
769769 */
770770 olcs . core . olPointGeometryToCesium = function ( geometry , projection , style ,
771- billboards , featureId , opt_featureToCesiumMap ) {
771+ billboards , opt_newBillboardCallback ) {
772772 goog . asserts . assert ( geometry . getType ( ) == 'Point' ) ;
773773 geometry = olGeometryCloneTo4326 ( geometry , projection ) ;
774774
@@ -793,9 +793,8 @@ goog.require('olcs.core.OlLayerPrimitive');
793793 verticalOrigin : Cesium . VerticalOrigin . BOTTOM ,
794794 position : position
795795 } ) ;
796- bb . olFeatureId = featureId ;
797- if ( goog . isDef ( opt_featureToCesiumMap ) ) {
798- opt_featureToCesiumMap [ featureId ] = bb ;
796+ if ( opt_newBillboardCallback ) {
797+ opt_newBillboardCallback ( bb ) ;
799798 }
800799 } ;
801800
@@ -823,12 +822,13 @@ goog.require('olcs.core.OlLayerPrimitive');
823822 * @param {!ol.geom.Geometry } geometry Ol3 geometry.
824823 * @param {!ol.proj.ProjectionLike } projection
825824 * @param {!ol.style.Style } olStyle
826- * @param {? } featureId
825+ * @param {function(!Cesium.Billboard)= } opt_newBillboardCallback Called when
826+ * the new billboard is added.
827827 * @return {!Cesium.Primitive } primitives
828828 * @api
829829 */
830830 olcs . core . olMultiGeometryToCesium = function ( geometry , projection ,
831- olStyle , featureId ) {
831+ olStyle , opt_newBillboardCallback ) {
832832 // Do not reproject to 4326 now because it will be done later.
833833
834834 // FIXME: would be better to combine all child geometries in one primitive
@@ -853,7 +853,7 @@ goog.require('olcs.core.OlLayerPrimitive');
853853 goog . array . forEach ( subgeos , function ( geometry ) {
854854 goog . asserts . assert ( geometry ) ;
855855 var result = fn ( geometry , projection , olStyle , billboards ,
856- featureId ) ;
856+ opt_newBillboardCallback ) ;
857857 if ( result ) {
858858 primitives . add ( result ) ;
859859 }
@@ -862,7 +862,8 @@ goog.require('olcs.core.OlLayerPrimitive');
862862 } else {
863863 goog . array . forEach ( subgeos , function ( geometry ) {
864864 goog . asserts . assert ( ! goog . isNull ( geometry ) ) ;
865- fn ( geometry , projection , olStyle , billboards , featureId ) ;
865+ fn ( geometry , projection , olStyle , billboards ,
866+ opt_newBillboardCallback ) ;
866867 } ) ;
867868 return billboards ;
868869 }
@@ -1083,9 +1084,14 @@ goog.require('olcs.core.OlLayerPrimitive');
10831084 var geom = opt_geom || feature . getGeometry ( ) ;
10841085 var proj = context . projection ;
10851086
1086- var id = function ( primitives ) {
1087- primitives . olFeatureId = goog . getUid ( feature ) ;
1088- return primitives ;
1087+ var id = function ( object ) {
1088+ object . olFeature = feature ;
1089+ return object ;
1090+ } ;
1091+
1092+ var newBillboardAddedCallback = function ( bb ) {
1093+ context . featureToCesiumMap [ goog . getUid ( feature ) ] = bb ;
1094+ id ( bb ) ;
10891095 } ;
10901096
10911097 switch ( geom . getType ( ) ) {
@@ -1106,7 +1112,7 @@ goog.require('olcs.core.OlLayerPrimitive');
11061112 geom = /** @type {!ol.geom.Point } */ ( geom ) ;
11071113 var bbs = context . billboards ;
11081114 var result = olcs . core . olPointGeometryToCesium ( geom , proj , style , bbs ,
1109- goog . getUid ( feature ) , context . featureToCesiumMap ) ;
1115+ newBillboardAddedCallback ) ;
11101116 if ( ! result ) {
11111117 // no wrapping primitive
11121118 return null ;
@@ -1126,7 +1132,7 @@ goog.require('olcs.core.OlLayerPrimitive');
11261132 case 'MultiLineString' :
11271133 case 'MultiPolygon' :
11281134 return id ( olcs . core . olMultiGeometryToCesium ( geom , proj , style ,
1129- goog . getUid ( feature ) ) ) ;
1135+ newBillboardAddedCallback ) ) ;
11301136 case 'LinearRing' :
11311137 throw new Error ( 'LinearRing should only be part of polygon.' ) ;
11321138 default :
0 commit comments