@@ -11,12 +11,24 @@ goog.require('olcs.VectorSynchronizer');
1111
1212
1313/**
14- * @param {!ol.Map } map
14+ * @param {!(olcsx.OLCesiumOptions| ol.Map) } options Options.
1515 * @param {Element|string= } opt_target Target element for the Cesium container.
16+ * Use the `target` option in `options` instead.
1617 * @constructor
1718 * @api
1819 */
19- olcs . OLCesium = function ( map , opt_target ) {
20+ olcs . OLCesium = function ( options , opt_target ) {
21+
22+ var map , createSynchronizers ;
23+ var target = opt_target ;
24+ if ( options instanceof ol . Map ) {
25+ map = options ;
26+ } else {
27+ map = options . map ;
28+ target = options . target ;
29+ createSynchronizers = options . createSynchronizers ;
30+ }
31+
2032 /**
2133 * @type {!ol.Map }
2234 * @private
@@ -32,7 +44,7 @@ olcs.OLCesium = function(map, opt_target) {
3244 this . container_ = goog . dom . createDom ( goog . dom . TagName . DIV ,
3345 { style : fillArea + 'visibility:hidden;' } ) ;
3446
35- var targetElement = goog . dom . getElement ( opt_target || null ) ;
47+ var targetElement = goog . dom . getElement ( target || null ) ;
3648 if ( targetElement ) {
3749 goog . dom . appendChild ( targetElement , this . container_ ) ;
3850 } else {
@@ -121,17 +133,16 @@ olcs.OLCesium = function(map, opt_target) {
121133 this . scene_ . globe = this . globe_ ;
122134 this . scene_ . skyAtmosphere = new Cesium . SkyAtmosphere ( ) ;
123135
124- /**
125- * @type {!olcs.RasterSynchronizer }
126- * @private
127- */
128- this . rasterSynchronizer_ = new olcs . RasterSynchronizer ( this . map_ ,
129- this . scene_ ) ;
130- this . rasterSynchronizer_ . synchronize ( ) ;
136+ var synchronizers = goog . isDef ( createSynchronizers ) ?
137+ createSynchronizers ( this . map_ , this . scene_ ) :
138+ [
139+ new olcs . RasterSynchronizer ( this . map_ , this . scene_ ) ,
140+ new olcs . VectorSynchronizer ( this . map_ , this . scene_ )
141+ ] ;
131142
132- this . vectorSynchronizer_ = new olcs . VectorSynchronizer ( this . map_ ,
133- this . scene_ ) ;
134- this . vectorSynchronizer_ . synchronize ( ) ;
143+ for ( var i = synchronizers . length - 1 ; i >= 0 ; -- i ) {
144+ synchronizers [ i ] . synchronize ( ) ;
145+ }
135146
136147 if ( this . isOverMap_ ) {
137148 // if in "stacked mode", hide everything except canvas (including credits)
0 commit comments