@@ -45,6 +45,7 @@ import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup';
4545import { createSymbol , ECSymbol } from '../../util/symbol' ;
4646import { LegendIconParams } from '../../component/legend/LegendModel' ;
4747import { Group } from '../../util/graphic' ;
48+ import { GeoJSONRegion } from '../../coord/geo/Region' ;
4849
4950export interface MapStateOption < TCbParams = never > {
5051 itemStyle ?: GeoItemStyleOption < TCbParams >
@@ -117,26 +118,36 @@ class MapSeries extends SeriesModel<MapSeriesOption> {
117118 coordDimensions : [ 'value' ] ,
118119 encodeDefaulter : zrUtil . curry ( makeSeriesEncodeForNameBased , this )
119120 } ) ;
120- const dataNameMap = zrUtil . createHashMap ( ) ;
121- const toAppendNames = [ ] as string [ ] ;
121+ const dataNameIndexMap = zrUtil . createHashMap < number > ( ) ;
122+ const toAppendItems : MapDataItemOption [ ] = [ ] ;
122123
123124 for ( let i = 0 , len = data . count ( ) ; i < len ; i ++ ) {
124125 const name = data . getName ( i ) ;
125- dataNameMap . set ( name , true ) ;
126+ dataNameIndexMap . set ( name , i ) ;
126127 }
127128
128129 const geoSource = geoSourceManager . load ( this . getMapType ( ) , this . option . nameMap , this . option . nameProperty ) ;
129130 zrUtil . each ( geoSource . regions , function ( region ) {
130131 const name = region . name ;
131- if ( ! dataNameMap . get ( name ) ) {
132- toAppendNames . push ( name ) ;
132+ const dataNameIdx = dataNameIndexMap . get ( name ) ;
133+ // apply specified echarts style in GeoJSON data
134+ const specifiedGeoJSONRegionStyle = ( region as GeoJSONRegion ) . properties
135+ && ( region as GeoJSONRegion ) . properties . echartsStyle ;
136+ let dataItem : MapDataItemOption ;
137+ if ( dataNameIdx == null ) {
138+ dataItem = { name : name } ;
139+ toAppendItems . push ( dataItem ) ;
133140 }
141+ else {
142+ dataItem = data . getRawDataItem ( dataNameIdx ) as MapDataItemOption ;
143+ }
144+ specifiedGeoJSONRegionStyle && zrUtil . merge ( dataItem , specifiedGeoJSONRegionStyle ) ;
134145 } ) ;
135146
136147 // Complete data with missing regions. The consequent processes (like visual
137148 // map and render) can not be performed without a "full data". For example,
138149 // find `dataIndex` by name.
139- data . appendValues ( [ ] , toAppendNames ) ;
150+ data . appendData ( toAppendItems ) ;
140151
141152 return data ;
142153 }
0 commit comments