Skip to content

Commit

Permalink
Merge pull request #20561 from apache/feat/geo/styling-in-geojson
Browse files Browse the repository at this point in the history
feat(geo): support styling region in original GeoJSON data
  • Loading branch information
plainheart authored Dec 5, 2024
2 parents 2009644 + 8f39773 commit 5d1d34e
Show file tree
Hide file tree
Showing 3 changed files with 546 additions and 448 deletions.
4 changes: 4 additions & 0 deletions src/component/helper/MapDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ class MapDraw {
? mapOrGeoModel.getRegionModel(regionName)
: (data ? data.getItemModel(dataIdx) as Model<MapDataItemOption> : null);

// allow specified echarts style in GeoJSON data
const specifiedRegionStyle = region.properties && region.properties.echartsStyle;
specifiedRegionStyle && zrUtil.merge(regionModel.option, specifiedRegionStyle);

regionsInfoByName.set(regionName, { dataIdx, regionModel });
}

Expand Down
7 changes: 5 additions & 2 deletions src/coord/geo/Region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import * as vec2 from 'zrender/src/core/vector';
import * as polygonContain from 'zrender/src/contain/polygon';
import { GeoJSON, GeoProjection, GeoSVGGraphicRoot } from './geoTypes';
import * as matrix from 'zrender/src/core/matrix';
import Element from 'zrender/src/Element';
import type Element from 'zrender/src/Element';
import { each } from 'zrender/src/core/util';
import type { RegoinOption } from './GeoModel';

const TMP_TRANSFORM = [] as number[];

Expand Down Expand Up @@ -135,7 +136,9 @@ export class GeoJSONRegion extends Region {
readonly geometries: (GeoJSONPolygonGeometry | GeoJSONLineStringGeometry)[];

// Injected outside.
properties: GeoJSON['features'][0]['properties'];
properties: GeoJSON['features'][0]['properties'] & {
echartsStyle?: Omit<RegoinOption, 'name' | 'selected'>
};

constructor(
name: string,
Expand Down
Loading

0 comments on commit 5d1d34e

Please sign in to comment.