geo component provides a geographic coordinate system for displaying map-based visualizations. It supports both GeoJSON and SVG map sources, with optional projections for accurate geographic representations.
When to Use
Use the geo component when you need to:- Display data on geographic maps (countries, regions, custom territories)
- Create choropleth maps with colored regions
- Visualize geographic distributions and patterns
- Show location-based data with proper spatial relationships
- Enable map interactions like zooming, panning, and region selection
Basic Configuration
With Projection
Use custom projections for accurate geographic representations:Region Configuration
Customize individual regions with specific styles:Properties
Whether to show the geo component.Source:
GeoModel.ts:170Map name. Must correspond to a map registered via
echarts.registerMap().Source: GeoModel.ts:89, 190Distance from the left side of the container.Source:
GeoModel.ts:172Distance from the top of the container.Source:
GeoModel.ts:174Center point of the map view in longitude and latitude. Default is the center of the map’s bounding box.Source:
GeoModel.ts:197Zoom level of the map. Higher values zoom in.Source:
GeoModel.ts:199Scale factor for the aspect ratio (width/height). This parameter scales the original aspect.
- For GeoJSON source: defaults to 0.75
- For SVG source: defaults to 1
GeoModel.ts:93, 179Center position for layout with fixed aspect ratio. For example:
['50%', '50%']. When set, center and zoom don’t work.Source: GeoModel.ts:99Size for layout. Can be absolute pixels or percentage string like
'50%'.Source: GeoModel.ts:101Define left-top and right-bottom lng/lat coords to control view. For example:
[[180, 90], [-180, -90]]. Has higher priority than center and zoom.Source: GeoModel.ts:110, 194Whether to enable mouse zooming and panning roaming. Can be:
false: disable roaming'scale': only enable scaling'move': only enable panningtrue: enable both scaling and panning
Custom projection for the map. Only available for GeoJSON sources. Must provide both
project and unproject functions.Source: GeoModel.ts:121Name mapping for customizing region names. Useful for translation or aliasing.Source:
GeoModel.ts:112Custom property name for region identification in the GeoJSON.Source:
GeoModel.ts:113Selection mode for regions:
false: disable selection'single': single region selection'multiple': multiple region selection
GeoModel.ts:142Configuration for individual regions. Each region can have custom styles and behaviors.Source:
GeoModel.ts:138, 239Style for all regions:
areaColor: Fill color of the regionborderColor: Border colorborderWidth: Border width
GeoModel.ts:210-217Label configuration for regions:
show: Whether to show labelscolor: Label text colorformatter: Label formatter function or template
GeoModel.ts:205-208Style configuration for the emphasis state (hover).Source:
GeoModel.ts:219-227Style configuration for the selected state.Source:
GeoModel.ts:229-237Whether the component is silent (no interaction).Source:
GeoModel.ts:187z-index of the component.Source:
GeoModel.ts:168Limits for zooming scale.Source:
GeoModel.ts:201Implementation Details
The Geo class extends View and provides geographic coordinate functionality. Key implementation details fromGeo.ts:
Dimensions
Geo uses two dimensions:['lng', 'lat'] for longitude and latitude (source: Geo.ts:49, 54).
Map Sources
Supports two resource types (source:Geo.ts:60):
'geoJSON': Standard GeoJSON format with default aspectScale of 0.75'geoSVG': SVG-based maps with default aspectScale of 1
Coordinate Conversion
Provides methods for coordinate transformation:dataToPoint(data, noRoam)- Convert lng/lat or region name to canvas point (source:Geo.ts:206-219)pointToData(point)- Convert canvas point to lng/lat coordinates (source:Geo.ts:221-230)getGeoCoord(name)- Get coordinates for a named region (source:Geo.ts:200-204)
Projection Support
When a projection is specified (source:Geo.ts:91, 121):
- The
projectfunction converts geographic coordinates to projected coordinates - The
unprojectfunction converts projected coordinates back to geographic - Projection is only supported for GeoJSON sources, not SVG (source:
Geo.ts:107-113)
Region Management
The geo component maintains:- A map of regions by name (source:
Geo.ts:64) - An array of all regions (source:
Geo.ts:66, 99) - Named coordinate lookup via
addGeoCoordandgetGeoCoord(source:Geo.ts:193-204)
Related Components
- Map Chart - Thematic map visualization using geo component
- Scatter Chart - Can use geo as coordinate system for geographic scatter plots