File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
packages/maptalks/src/geometry Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -496,9 +496,26 @@ export class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
496496 return this ;
497497 }
498498 let s = this . _getSymbol ( ) ;
499+ const propsIsArray = Array . isArray ( props ) ;
500+ if ( ! s ) {
501+ //generate defalut empty symbol
502+ s = { } ;
503+ if ( propsIsArray ) {
504+ s = props . map ( ( ) => { return { } } ) ;
505+ }
506+ }
507+ if ( ! Array . isArray ( s ) && propsIsArray ) {
508+ //only read first element of props
509+ props = props [ 0 ] || { } ;
510+ }
499511 if ( Array . isArray ( s ) ) {
500- if ( ! Array . isArray ( props ) ) {
501- throw new Error ( 'Parameter of updateSymbol is not an array.' ) ;
512+ if ( ! propsIsArray ) {
513+ //auto generate array symbol
514+ props = [ props ] ;
515+ while ( props . length < s . length ) {
516+ props . push ( { } ) ;
517+ }
518+ // throw new Error('Parameter of updateSymbol is not an array.');
502519 }
503520 for ( let i = 0 ; i < props . length ; i ++ ) {
504521 if ( isTextSymbol ( props [ i ] ) ) {
@@ -509,7 +526,10 @@ export class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
509526 }
510527 }
511528 } else if ( Array . isArray ( props ) ) {
512- throw new Error ( 'Geometry\'s symbol is not an array to update.' ) ;
529+ // throw new Error('Geometry\'s symbol is object but the update symbol is array.');
530+ console . error ( 'Geometry\'s symbol is object but the update symbol is array.' ) ;
531+ console . error ( 'Geometry\'s symbol and update symbol:' , s , props ) ;
532+ return this ;
513533 } else {
514534 if ( isTextSymbol ( s ) ) {
515535 delete this . _textDesc ;
You can’t perform that action at this time.
0 commit comments