diff --git a/src/coord/geo/Geo.ts b/src/coord/geo/Geo.ts index a2e96cc2ee415ca2442759420a9ea0b4ca7194eb..aa15eba1e151bd838df7eaa2b1a2eb581de1d8bc 100644 --- a/src/coord/geo/Geo.ts +++ b/src/coord/geo/Geo.ts @@ -56,7 +56,7 @@ class Geo extends View { readonly resourceType: GeoResource['type']; // Only store specified name coord via `addGeoCoord`. - private _nameCoordMap: zrUtil.HashMap; + private _nameCoordMap: zrUtil.HashMap = zrUtil.createHashMap(); private _regionsMap: zrUtil.HashMap; private _invertLongitute: boolean; readonly regions: Region[]; diff --git a/src/coord/geo/Region.ts b/src/coord/geo/Region.ts index df482e378ae385ff19bafc4c3728ea5f0f3c81cc..2e5248ed944e0683fa69cdbab29d936be68ca42d 100644 --- a/src/coord/geo/Region.ts +++ b/src/coord/geo/Region.ts @@ -42,7 +42,7 @@ export class Region { /** * Get center point in data unit. That is, * for GeoJSONRegion, the unit is lat/lng, - * for GeoSVGRegion, the unit is pixel but based on root. + * for GeoSVGRegion, the unit is SVG local coord. */ getCenter(): number[] { return; @@ -239,8 +239,8 @@ export class GeoSVGRegion extends Region { const el = this._elOnlyForCalculate; const rect = el.getBoundingRect(); const center = [ - rect.x + rect.width, - rect.y + rect.height + rect.x + rect.width / 2, + rect.y + rect.height / 2 ]; const mat = matrix.identity(TMP_TRANSFORM); diff --git a/test/geo-svg.html b/test/geo-svg.html index 38a625109ae71671872678adc2eb318112c60ca1..9f0f5e943e08d84bfda7ebf2c829db539919c896 100644 --- a/test/geo-svg.html +++ b/test/geo-svg.html @@ -39,6 +39,7 @@ under the License.
+
@@ -174,14 +175,13 @@ under the License. // layoutCenter: ['30%', 40], // layoutSize: 40, // boundingCoords - zoom: 1, - aspectScale: 1 + // zoom: 1, + // aspectScale: 1 } }; var chart = testHelper.create(echarts, 'main_simple_geo_svg', { title: [ - 'simple geo geoSVG location:', 'Should be a square and 80% of canvas height.', 'At the center of the canvas.' ], @@ -202,6 +202,101 @@ under the License. + + + + + +