(nameProperty: string)
| 95 | } |
| 96 | |
| 97 | private _parseToRegions(nameProperty: string): GeoJSONRegion[] { |
| 98 | const mapName = this._mapName; |
| 99 | const geoJSON = this._geoJSON; |
| 100 | let rawRegions; |
| 101 | |
| 102 | // https://jsperf.com/try-catch-performance-overhead |
| 103 | try { |
| 104 | rawRegions = geoJSON ? parseGeoJson(geoJSON, nameProperty) : []; |
| 105 | } |
| 106 | catch (e) { |
| 107 | throw new Error('Invalid geoJson format\n' + e.message); |
| 108 | } |
| 109 | |
| 110 | fixNanhai(mapName, rawRegions); |
| 111 | |
| 112 | each(rawRegions, function (region) { |
| 113 | const regionName = region.name; |
| 114 | |
| 115 | fixTextCoord(mapName, region); |
| 116 | fixDiaoyuIsland(mapName, region); |
| 117 | |
| 118 | // Some area like Alaska in USA map needs to be tansformed |
| 119 | // to look better |
| 120 | const specialArea = this._specialAreas && this._specialAreas[regionName]; |
| 121 | if (specialArea) { |
| 122 | region.transformTo( |
| 123 | specialArea.left, specialArea.top, specialArea.width, specialArea.height |
| 124 | ); |
| 125 | } |
| 126 | }, this); |
| 127 | |
| 128 | return rawRegions; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Only for exporting to users. |
no test coverage detected