react-native-map4d-map-dtqg 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +133 -41
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +60 -60
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/com/reactnativemap4dmap/ImageUtils.java +87 -87
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapModule.java +298 -298
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapPackage.java +35 -35
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapViewManager.java +31 -31
- package/android/src/main/java/com/reactnativemap4dmap/RMFBuilding.java +167 -167
- package/android/src/main/java/com/reactnativemap4dmap/RMFBuildingManager.java +121 -121
- package/android/src/main/java/com/reactnativemap4dmap/RMFCircle.java +105 -105
- package/android/src/main/java/com/reactnativemap4dmap/RMFCircleManager.java +121 -121
- package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRenderer.java +502 -502
- package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRendererManager.java +143 -143
- package/android/src/main/java/com/reactnativemap4dmap/RMFFeature.java +17 -17
- package/android/src/main/java/com/reactnativemap4dmap/RMFMapView.java +1172 -1172
- package/android/src/main/java/com/reactnativemap4dmap/RMFMapViewManager.java +231 -226
- package/android/src/main/java/com/reactnativemap4dmap/RMFMarker.java +412 -412
- package/android/src/main/java/com/reactnativemap4dmap/RMFMarkerManager.java +211 -211
- package/android/src/main/java/com/reactnativemap4dmap/RMFPOI.java +222 -222
- package/android/src/main/java/com/reactnativemap4dmap/RMFPOIManager.java +119 -119
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolygon.java +172 -172
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolygonManager.java +147 -147
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolyline.java +146 -146
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolylineManager.java +137 -137
- package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlay.java +95 -95
- package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlayManager.java +64 -64
- package/android/src/main/java/com/reactnativemap4dmap/SizeReportingShadowNode.java +31 -31
- package/android/src/main/java/com/reactnativemap4dmap/ViewAttacherGroup.java +31 -31
- package/android/src/main/java/com/reactnativemap4dmap/ViewChangesTracker.java +70 -70
- package/android/src/main/java/vn/map4d/map/annotations/RMFBitmapDescriptor.java +9 -9
- package/ios/Map4dMap.h +7 -7
- package/ios/Map4dMap.m +14 -14
- package/ios/Map4dMapViewManager.m +34 -34
- package/ios/RCTConvert+Map4dMap.h +33 -33
- package/ios/RCTConvert+Map4dMap.m +112 -112
- package/ios/RMFCircle.h +37 -37
- package/ios/RMFCircle.m +100 -100
- package/ios/RMFCircleManager.h +18 -18
- package/ios/RMFCircleManager.m +155 -155
- package/ios/RMFCircleMap4d.h +23 -23
- package/ios/RMFCircleMap4d.m +13 -13
- package/ios/RMFCoordinate.h +22 -22
- package/ios/RMFCoordinate.m +13 -13
- package/ios/RMFDirectionsMarkerOptions.h +24 -24
- package/ios/RMFDirectionsMarkerOptions.m +23 -23
- package/ios/RMFDirectionsRenderer.h +47 -47
- package/ios/RMFDirectionsRenderer.m +182 -182
- package/ios/RMFDirectionsRendererManager.h +17 -17
- package/ios/RMFDirectionsRendererManager.m +84 -84
- package/ios/RMFDirectionsRendererMap4d.h +21 -21
- package/ios/RMFDirectionsRendererMap4d.m +12 -12
- package/ios/RMFDummyView.h +6 -6
- package/ios/RMFDummyView.m +12 -12
- package/ios/RMFEventResponse.h +39 -39
- package/ios/RMFEventResponse.m +98 -98
- package/ios/RMFIcon.h +24 -24
- package/ios/RMFIcon.m +35 -35
- package/ios/RMFMapView.h +84 -84
- package/ios/RMFMapView.m +376 -376
- package/ios/RMFMapViewManager.h +17 -17
- package/ios/RMFMapViewManager.m +508 -493
- package/ios/RMFMarker.h +57 -57
- package/ios/RMFMarker.m +267 -267
- package/ios/RMFMarkerManager.h +17 -17
- package/ios/RMFMarkerManager.m +156 -156
- package/ios/RMFMarkerMap4d.h +19 -19
- package/ios/RMFMarkerMap4d.m +13 -13
- package/ios/RMFPOI.h +38 -38
- package/ios/RMFPOI.m +123 -123
- package/ios/RMFPOIManager.h +18 -18
- package/ios/RMFPOIManager.m +168 -168
- package/ios/RMFPOIMap4d.h +22 -22
- package/ios/RMFPOIMap4d.m +12 -12
- package/ios/RMFPolygon.h +41 -41
- package/ios/RMFPolygon.m +106 -106
- package/ios/RMFPolygonManager.h +18 -18
- package/ios/RMFPolygonManager.m +141 -141
- package/ios/RMFPolygonMap4d.h +23 -23
- package/ios/RMFPolygonMap4d.m +15 -15
- package/ios/RMFPolyline.h +38 -38
- package/ios/RMFPolyline.m +101 -101
- package/ios/RMFPolylineManager.h +18 -18
- package/ios/RMFPolylineManager.m +139 -139
- package/ios/RMFPolylineMap4d.h +22 -22
- package/ios/RMFPolylineMap4d.m +15 -15
- package/ios/building/RMFBuilding.h +41 -41
- package/ios/building/RMFBuilding.m +104 -104
- package/ios/building/RMFBuildingManager.h +19 -19
- package/ios/building/RMFBuildingManager.m +133 -133
- package/ios/building/RMFBuildingMap4d.h +23 -23
- package/ios/building/RMFBuildingMap4d.m +15 -15
- package/ios/overlays/RMFTileOverlay.h +36 -36
- package/ios/overlays/RMFTileOverlay.m +64 -64
- package/ios/overlays/RMFTileOverlayManager.h +17 -17
- package/ios/overlays/RMFTileOverlayManager.m +27 -27
- package/lib/commonjs/components/MFBanDoSo.js +109 -0
- package/lib/commonjs/components/MFBanDoSo.js.map +1 -0
- package/lib/commonjs/components/MFBuilding.js +26 -26
- package/lib/commonjs/components/MFBuilding.js.map +1 -1
- package/lib/commonjs/components/MFCircle.js +20 -20
- package/lib/commonjs/components/MFCircle.js.map +1 -1
- package/lib/commonjs/components/MFDirectionsRenderer.js +32 -32
- package/lib/commonjs/components/MFDirectionsRenderer.js.map +1 -1
- package/lib/commonjs/components/MFMapView.js +152 -71
- package/lib/commonjs/components/MFMapView.js.map +1 -1
- package/lib/commonjs/components/MFMarker.js +35 -35
- package/lib/commonjs/components/MFMarker.js.map +1 -1
- package/lib/commonjs/components/MFPOI.js +20 -20
- package/lib/commonjs/components/MFPOI.js.map +1 -1
- package/lib/commonjs/components/MFPolygon.js +22 -22
- package/lib/commonjs/components/MFPolygon.js.map +1 -1
- package/lib/commonjs/components/MFPolyline.js +18 -18
- package/lib/commonjs/components/MFPolyline.js.map +1 -1
- package/lib/commonjs/components/MFTileOverlay.js +9 -9
- package/lib/commonjs/components/MFTileOverlay.js.map +1 -1
- package/lib/commonjs/components/Map4dMapView.js.map +1 -1
- package/lib/commonjs/components/extends/AreaFocusManager.js +205 -0
- package/lib/commonjs/components/extends/AreaFocusManager.js.map +1 -0
- package/lib/commonjs/components/extends/AreaFocuser.js +73 -0
- package/lib/commonjs/components/extends/AreaFocuser.js.map +1 -0
- package/lib/commonjs/components/extends/BoundHelper.js +36 -0
- package/lib/commonjs/components/extends/BoundHelper.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusAreas.js +167 -0
- package/lib/commonjs/components/extends/area/AreaFocusAreas.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusGeometryUtils.js +164 -0
- package/lib/commonjs/components/extends/area/AreaFocusGeometryUtils.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusSession.js +100 -0
- package/lib/commonjs/components/extends/area/AreaFocusSession.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusTypes.js +40 -0
- package/lib/commonjs/components/extends/area/AreaFocusTypes.js.map +1 -0
- package/lib/commonjs/components/internal/DefaultRoadmapStyle.js +2288 -0
- package/lib/commonjs/components/internal/DefaultRoadmapStyle.js.map +1 -0
- package/lib/commonjs/components/internal/GeojsonStyleUtils.js +139 -0
- package/lib/commonjs/components/internal/GeojsonStyleUtils.js.map +1 -0
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/MFBanDoSo.js +92 -0
- package/lib/module/components/MFBanDoSo.js.map +1 -0
- package/lib/module/components/MFBuilding.js +26 -26
- package/lib/module/components/MFBuilding.js.map +1 -1
- package/lib/module/components/MFCircle.js +20 -20
- package/lib/module/components/MFCircle.js.map +1 -1
- package/lib/module/components/MFDirectionsRenderer.js +32 -32
- package/lib/module/components/MFDirectionsRenderer.js.map +1 -1
- package/lib/module/components/MFMapView.js +149 -71
- package/lib/module/components/MFMapView.js.map +1 -1
- package/lib/module/components/MFMarker.js +35 -35
- package/lib/module/components/MFMarker.js.map +1 -1
- package/lib/module/components/MFPOI.js +20 -20
- package/lib/module/components/MFPOI.js.map +1 -1
- package/lib/module/components/MFPolygon.js +22 -22
- package/lib/module/components/MFPolygon.js.map +1 -1
- package/lib/module/components/MFPolyline.js +18 -18
- package/lib/module/components/MFPolyline.js.map +1 -1
- package/lib/module/components/MFTileOverlay.js +9 -9
- package/lib/module/components/MFTileOverlay.js.map +1 -1
- package/lib/module/components/Map4dMapView.js.map +1 -1
- package/lib/module/components/extends/AreaFocusManager.js +193 -0
- package/lib/module/components/extends/AreaFocusManager.js.map +1 -0
- package/lib/module/components/extends/AreaFocuser.js +64 -0
- package/lib/module/components/extends/AreaFocuser.js.map +1 -0
- package/lib/module/components/extends/BoundHelper.js +29 -0
- package/lib/module/components/extends/BoundHelper.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusAreas.js +156 -0
- package/lib/module/components/extends/area/AreaFocusAreas.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusGeometryUtils.js +153 -0
- package/lib/module/components/extends/area/AreaFocusGeometryUtils.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusSession.js +93 -0
- package/lib/module/components/extends/area/AreaFocusSession.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusTypes.js +33 -0
- package/lib/module/components/extends/area/AreaFocusTypes.js.map +1 -0
- package/lib/module/components/internal/DefaultRoadmapStyle.js +2281 -0
- package/lib/module/components/internal/DefaultRoadmapStyle.js.map +1 -0
- package/lib/module/components/internal/GeojsonStyleUtils.js +130 -0
- package/lib/module/components/internal/GeojsonStyleUtils.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/Map4dMapView.d.ts +7 -7
- package/package.json +152 -152
- package/react-native-map4d-map.podspec +20 -20
- package/src/components/MFBanDoSo.js +124 -0
- package/src/components/MFBuilding.js +187 -187
- package/src/components/MFCircle.js +173 -173
- package/src/components/MFDirectionsRenderer.js +237 -237
- package/src/components/MFMapView.js +464 -373
- package/src/components/MFMarker.js +246 -246
- package/src/components/MFPOI.js +184 -184
- package/src/components/MFPolygon.js +186 -186
- package/src/components/MFPolyline.js +172 -172
- package/src/components/MFTileOverlay.js +45 -45
- package/src/components/Map4dMapView.tsx +26 -26
- package/src/components/extends/AreaFocusManager.js +196 -0
- package/src/components/extends/AreaFocuser.js +62 -0
- package/src/components/extends/BoundHelper.js +32 -0
- package/src/components/extends/area/AreaFocusAreas.js +164 -0
- package/src/components/extends/area/AreaFocusGeometryUtils.js +164 -0
- package/src/components/extends/area/AreaFocusSession.js +100 -0
- package/src/components/extends/area/AreaFocusTypes.js +36 -0
- package/src/components/internal/DefaultRoadmapStyle.js +3365 -0
- package/src/components/internal/GeojsonStyleUtils.js +143 -0
- package/src/index.js +25 -21
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class AreaFocuser {
|
|
2
|
+
|
|
3
|
+
constructor(areaFocusManager) {
|
|
4
|
+
this._areaFocusManager = areaFocusManager
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {{name?: string, highlight?: boolean}=} options
|
|
9
|
+
*/
|
|
10
|
+
async focusProvince(options) {
|
|
11
|
+
const provinceName = this._getProvinceName(options)
|
|
12
|
+
const shouldHighlight = this._shouldHighlight(options)
|
|
13
|
+
|
|
14
|
+
if (!provinceName) {
|
|
15
|
+
this._clear()
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (this._areaFocusManager) {
|
|
20
|
+
await this._areaFocusManager.focus({
|
|
21
|
+
type: 'province',
|
|
22
|
+
name: provinceName,
|
|
23
|
+
display: shouldHighlight ? 'highlight' : 'normal',
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_clear() {
|
|
29
|
+
if (this._areaFocusManager) {
|
|
30
|
+
this._areaFocusManager.clear()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_getProvinceName(options) {
|
|
35
|
+
if (options == null || typeof options !== 'object') {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof options.name === 'string') {
|
|
40
|
+
return options.name.trim()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const optionKeys = Object.keys(options)
|
|
44
|
+
const unsupportedKeys = optionKeys.filter((key) => key !== 'name' && key !== 'highlight')
|
|
45
|
+
|
|
46
|
+
if (unsupportedKeys.length > 0) {
|
|
47
|
+
console.warn(
|
|
48
|
+
`[AreaFocuser] focusProvince expects options like { name: 'Ha Noi', highlight: true }. Unsupported keys: ${unsupportedKeys.join(', ')}`
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_shouldHighlight(options) {
|
|
56
|
+
if (options == null || typeof options !== 'object') {
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return options.highlight === true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class BoundHelper {
|
|
2
|
+
static createEmptyBounds() {
|
|
3
|
+
return {
|
|
4
|
+
minLat: Infinity,
|
|
5
|
+
minLng: Infinity,
|
|
6
|
+
maxLat: -Infinity,
|
|
7
|
+
maxLng: -Infinity,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static updateBounds(bounds, lat, lng) {
|
|
12
|
+
bounds.minLat = Math.min(bounds.minLat, lat)
|
|
13
|
+
bounds.minLng = Math.min(bounds.minLng, lng)
|
|
14
|
+
bounds.maxLat = Math.max(bounds.maxLat, lat)
|
|
15
|
+
bounds.maxLng = Math.max(bounds.maxLng, lng)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static isValidBounds(bounds) {
|
|
19
|
+
if (!bounds) {
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return !(
|
|
24
|
+
bounds.minLat === Infinity ||
|
|
25
|
+
bounds.minLng === Infinity ||
|
|
26
|
+
bounds.maxLat === -Infinity ||
|
|
27
|
+
bounds.maxLng === -Infinity
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {BoundHelper}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {getViewboxFromGeometry} from './AreaFocusGeometryUtils'
|
|
2
|
+
import {IndustrialEconomicType} from './AreaFocusTypes'
|
|
3
|
+
|
|
4
|
+
const INDUSTRIAL_ECONOMIC_PATH_BY_TYPE = {
|
|
5
|
+
[IndustrialEconomicType.INDUSTRIAL_ZONE]: 'khu-cong-nghiep',
|
|
6
|
+
[IndustrialEconomicType.ECONOMIC_ZONE]: 'khu-kinh-te',
|
|
7
|
+
[IndustrialEconomicType.ECO_INDUSTRIAL_ZONE]: 'khu-cong-nghiep-sinh-thai',
|
|
8
|
+
[IndustrialEconomicType.FREE_TRADE_ZONE]: 'khu-thuong-mai-tu-do',
|
|
9
|
+
[IndustrialEconomicType.NON_TARIFF_ZONE]: 'khu-phi-thue-quan',
|
|
10
|
+
[IndustrialEconomicType.OTHER_ZONE_MODEL]: 'mo-hinh-khu-khac',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const BDS_API_BASE_URL = 'https://cmcdtqg-gateway.dieuhanhso.vn/staging'
|
|
14
|
+
|
|
15
|
+
class ProvinceArea {
|
|
16
|
+
constructor(id) {
|
|
17
|
+
this.id = id
|
|
18
|
+
this.name = null
|
|
19
|
+
this.loaded = false
|
|
20
|
+
this.geometryData = null
|
|
21
|
+
this.bounds = null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static fromName(name) {
|
|
25
|
+
const area = new ProvinceArea(null)
|
|
26
|
+
area.name = name
|
|
27
|
+
return area
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async load() {
|
|
31
|
+
if (this.loaded) {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const hasValidId = typeof this.id === 'number'
|
|
36
|
+
const hasValidName = typeof this.name === 'string' && this.name.trim() !== ''
|
|
37
|
+
|
|
38
|
+
if (!hasValidId && !hasValidName) {
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const normalizedName = hasValidName ? this.name.trim() : null
|
|
43
|
+
const url = hasValidId
|
|
44
|
+
? `${BDS_API_BASE_URL}/bds/api/dmhc/TinhThanh/${this.id}/geometry`
|
|
45
|
+
: `${BDS_API_BASE_URL}/bds/api/dmhc/TinhThanh/geometry?ten=${encodeURIComponent(normalizedName)}`
|
|
46
|
+
|
|
47
|
+
const response = await fetch(url)
|
|
48
|
+
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const data = await response.json()
|
|
54
|
+
|
|
55
|
+
if (!data.success) {
|
|
56
|
+
console.error('Fetch province area data failed:', data.message)
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const areaData = data.data
|
|
61
|
+
const geometry = areaData && areaData.geometry ? areaData.geometry : null
|
|
62
|
+
|
|
63
|
+
if (!geometry) {
|
|
64
|
+
return false
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.geometryData = {
|
|
68
|
+
name: areaData && areaData.name ? areaData.name : normalizedName,
|
|
69
|
+
geometry,
|
|
70
|
+
}
|
|
71
|
+
this.bounds = getViewboxFromGeometry(geometry)
|
|
72
|
+
this.loaded = true
|
|
73
|
+
|
|
74
|
+
return true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getGeometryData() {
|
|
78
|
+
return this.geometryData
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getBounds() {
|
|
82
|
+
return this.bounds
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getId() {
|
|
86
|
+
return this.id != null ? this.id : `province-${this.name || 'unknown'}`
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class IndustrialEconomicArea {
|
|
91
|
+
constructor(type, id) {
|
|
92
|
+
this.type = type
|
|
93
|
+
this.id = id
|
|
94
|
+
this.loaded = false
|
|
95
|
+
this.geometryData = null
|
|
96
|
+
this.bounds = null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async load() {
|
|
100
|
+
if (this.loaded) {
|
|
101
|
+
return true
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (typeof this.id !== 'number') {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const pathSegment = INDUSTRIAL_ECONOMIC_PATH_BY_TYPE[this.type]
|
|
109
|
+
|
|
110
|
+
if (!pathSegment) {
|
|
111
|
+
console.error('Unsupported industrial/economic area type:', this.type)
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const url = `${BDS_API_BASE_URL}/bds/api/kcnkkt/${pathSegment}/${this.id}/geometry`
|
|
116
|
+
|
|
117
|
+
const response = await fetch(url)
|
|
118
|
+
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
console.error('Failed to fetch industrial zone data:', response.status, response.statusText)
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const data = await response.json()
|
|
125
|
+
|
|
126
|
+
if (!data.success) {
|
|
127
|
+
console.error('API returned error:', data.message)
|
|
128
|
+
return false
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const areaData = data.data
|
|
132
|
+
const geometry = areaData && areaData.geometry ? areaData.geometry : null
|
|
133
|
+
|
|
134
|
+
if (!geometry) {
|
|
135
|
+
return false
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.geometryData = {
|
|
139
|
+
name: areaData && areaData.name ? areaData.name : null,
|
|
140
|
+
geometry,
|
|
141
|
+
}
|
|
142
|
+
this.bounds = getViewboxFromGeometry(geometry)
|
|
143
|
+
this.loaded = true
|
|
144
|
+
|
|
145
|
+
return true
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getGeometryData() {
|
|
149
|
+
return this.geometryData
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getBounds() {
|
|
153
|
+
return this.bounds
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
getId() {
|
|
157
|
+
return this.id
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
ProvinceArea,
|
|
163
|
+
IndustrialEconomicArea,
|
|
164
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {BoundHelper} from '../BoundHelper'
|
|
2
|
+
|
|
3
|
+
const WORLD_MASK_PATH = [
|
|
4
|
+
{ longitude: -180, latitude: -90 },
|
|
5
|
+
{ longitude: 180, latitude: -90 },
|
|
6
|
+
{ longitude: 180, latitude: 90 },
|
|
7
|
+
{ longitude: -180, latitude: 90 },
|
|
8
|
+
{ longitude: -180, latitude: -90 },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
function parseViewbox(viewbox) {
|
|
12
|
+
const bounds = viewbox.split(',').map(Number)
|
|
13
|
+
|
|
14
|
+
if (bounds.length != 4) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const [minLat, minLng, maxLat, maxLng] = bounds
|
|
19
|
+
|
|
20
|
+
if (
|
|
21
|
+
Number.isNaN(minLat) ||
|
|
22
|
+
Number.isNaN(minLng) ||
|
|
23
|
+
Number.isNaN(maxLat) ||
|
|
24
|
+
Number.isNaN(maxLng)
|
|
25
|
+
) {
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
minLat,
|
|
31
|
+
minLng,
|
|
32
|
+
maxLat,
|
|
33
|
+
maxLng,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getViewboxFromGeometry(geometry) {
|
|
38
|
+
if (!geometry || typeof geometry !== 'object') {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const bounds = BoundHelper.createEmptyBounds()
|
|
43
|
+
|
|
44
|
+
const updateBounds = (coordinate) => {
|
|
45
|
+
if (!Array.isArray(coordinate) || coordinate.length < 2) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const lng = coordinate[0]
|
|
50
|
+
const lat = coordinate[1]
|
|
51
|
+
|
|
52
|
+
if (Number.isNaN(lat) || Number.isNaN(lng)) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
BoundHelper.updateBounds(bounds, lat, lng)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (geometry.type === 'Polygon') {
|
|
60
|
+
geometry.coordinates.forEach((ring) => {
|
|
61
|
+
ring.forEach((coordinate) => {
|
|
62
|
+
updateBounds(coordinate)
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (geometry.type === 'MultiPolygon') {
|
|
68
|
+
geometry.coordinates.forEach((polygon) => {
|
|
69
|
+
polygon.forEach((ring) => {
|
|
70
|
+
ring.forEach((coordinate) => {
|
|
71
|
+
updateBounds(coordinate)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!BoundHelper.isValidBounds(bounds)) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return bounds
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function convertAndClosePath(path) {
|
|
85
|
+
if (!Array.isArray(path) || path.length == 0) {
|
|
86
|
+
return []
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const coordinatePath = path
|
|
90
|
+
.filter((point) => Array.isArray(point) && point.length >= 2)
|
|
91
|
+
.map((point) => ({
|
|
92
|
+
latitude: point[1],
|
|
93
|
+
longitude: point[0],
|
|
94
|
+
}))
|
|
95
|
+
|
|
96
|
+
if (coordinatePath.length == 0) {
|
|
97
|
+
return []
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const firstPoint = coordinatePath[0]
|
|
101
|
+
const lastPoint = coordinatePath[coordinatePath.length - 1]
|
|
102
|
+
|
|
103
|
+
if (
|
|
104
|
+
firstPoint.latitude == lastPoint.latitude &&
|
|
105
|
+
firstPoint.longitude == lastPoint.longitude
|
|
106
|
+
) {
|
|
107
|
+
return coordinatePath
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return [
|
|
111
|
+
...coordinatePath,
|
|
112
|
+
firstPoint,
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function areaGeometryToPolygonPaths(geometry) {
|
|
117
|
+
const paths = []
|
|
118
|
+
|
|
119
|
+
if (!geometry || typeof geometry !== 'object') {
|
|
120
|
+
return paths
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (geometry.type === 'Polygon') {
|
|
124
|
+
if (Array.isArray(geometry.coordinates) && geometry.coordinates.length > 0) {
|
|
125
|
+
const path = convertAndClosePath(geometry.coordinates[0])
|
|
126
|
+
if (path.length > 0) {
|
|
127
|
+
paths.push(path)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return paths
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (geometry.type === 'MultiPolygon') {
|
|
134
|
+
geometry.coordinates.forEach((polygonCoordinates) => {
|
|
135
|
+
if (!Array.isArray(polygonCoordinates) || polygonCoordinates.length === 0) {
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const path = convertAndClosePath(polygonCoordinates[0])
|
|
140
|
+
if (path.length > 0) {
|
|
141
|
+
paths.push(path)
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return paths
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function createWorldMaskPaths(geometry) {
|
|
150
|
+
const holes = areaGeometryToPolygonPaths(geometry)
|
|
151
|
+
|
|
152
|
+
return [
|
|
153
|
+
WORLD_MASK_PATH,
|
|
154
|
+
...holes,
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export {
|
|
159
|
+
WORLD_MASK_PATH,
|
|
160
|
+
parseViewbox,
|
|
161
|
+
getViewboxFromGeometry,
|
|
162
|
+
areaGeometryToPolygonPaths,
|
|
163
|
+
createWorldMaskPaths,
|
|
164
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
areaGeometryToPolygonPaths,
|
|
3
|
+
createWorldMaskPaths,
|
|
4
|
+
} from './AreaFocusGeometryUtils'
|
|
5
|
+
|
|
6
|
+
class AreaFocusSession {
|
|
7
|
+
constructor(mapView, area, options) {
|
|
8
|
+
this.mapView = mapView
|
|
9
|
+
this.area = area
|
|
10
|
+
this.options = options || {}
|
|
11
|
+
this.polygonIds = []
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
this.clearPolygons()
|
|
16
|
+
|
|
17
|
+
const data = this.area.getGeometryData()
|
|
18
|
+
if (!data || !data.geometry) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const highlight = this.options.display === 'highlight'
|
|
23
|
+
|
|
24
|
+
if (highlight) {
|
|
25
|
+
this.renderHighlight(data.geometry)
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.renderNormal(data.geometry)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
destroy() {
|
|
33
|
+
this.clearPolygons()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
renderNormal(geometry) {
|
|
37
|
+
const polygons = areaGeometryToPolygonPaths(geometry)
|
|
38
|
+
|
|
39
|
+
polygons.forEach((coordinates, index) => {
|
|
40
|
+
this.addPolygon({
|
|
41
|
+
id: `${String(this.area.getId ? this.area.getId() : 'area')}-normal-${index}`,
|
|
42
|
+
coordinates,
|
|
43
|
+
fillColor: '#2196F3BF',
|
|
44
|
+
strokeColor: '#0D47A1FF',
|
|
45
|
+
strokeWidth: 1.5,
|
|
46
|
+
visible: true,
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
renderHighlight(geometry) {
|
|
52
|
+
const paths = createWorldMaskPaths(geometry)
|
|
53
|
+
|
|
54
|
+
if (paths.length <= 1) {
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const [coordinates, ...holes] = paths
|
|
59
|
+
|
|
60
|
+
this.addPolygon({
|
|
61
|
+
id: `${String(this.area.getId ? this.area.getId() : 'area')}-highlight`,
|
|
62
|
+
coordinates,
|
|
63
|
+
holes,
|
|
64
|
+
fillColor: '#0000001E',
|
|
65
|
+
strokeColor: '#FF0000FF',
|
|
66
|
+
strokeWidth: 2,
|
|
67
|
+
zIndex: 999,
|
|
68
|
+
visible: true,
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
addPolygon(polygon) {
|
|
73
|
+
if (!this.mapView || typeof this.mapView._addPolygon !== 'function') {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const id = this.mapView._addPolygon(polygon)
|
|
78
|
+
|
|
79
|
+
if (id != null) {
|
|
80
|
+
this.polygonIds.push(id)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
clearPolygons() {
|
|
85
|
+
if (!this.mapView || typeof this.mapView._removePolygon !== 'function') {
|
|
86
|
+
this.polygonIds = []
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.polygonIds.forEach((id) => {
|
|
91
|
+
this.mapView._removePolygon(id)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
this.polygonIds = []
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
AreaFocusSession,
|
|
100
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{type: 'Point', coordinates: [number, number]}} PointGeometry
|
|
3
|
+
* @typedef {Array<Array<[number, number]>>} PolygonCoordinates
|
|
4
|
+
* @typedef {{type: 'Polygon', coordinates: PolygonCoordinates}} PolygonGeometry
|
|
5
|
+
* @typedef {{type: 'MultiPolygon', coordinates: Array<PolygonCoordinates>}} MultiPolygonGeometry
|
|
6
|
+
* @typedef {PointGeometry | PolygonGeometry | MultiPolygonGeometry} AreaGeometry
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} GeometryData
|
|
11
|
+
* @property {string=} name
|
|
12
|
+
* @property {AreaGeometry=} geometry
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} FocusableArea
|
|
17
|
+
* @property {boolean} loaded
|
|
18
|
+
* @property {boolean} editable
|
|
19
|
+
* @property {() => Promise<boolean>} load
|
|
20
|
+
* @property {() => GeometryData | null} getGeometryData
|
|
21
|
+
* @property {() => {minLat: number, minLng: number, maxLat: number, maxLng: number} | null} getBounds
|
|
22
|
+
* @property {() => string | number | null=} getId
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const IndustrialEconomicType = {
|
|
26
|
+
INDUSTRIAL_ZONE: 1,
|
|
27
|
+
ECONOMIC_ZONE: 2,
|
|
28
|
+
ECO_INDUSTRIAL_ZONE: 3,
|
|
29
|
+
FREE_TRADE_ZONE: 4,
|
|
30
|
+
NON_TARIFF_ZONE: 5,
|
|
31
|
+
OTHER_ZONE_MODEL: 6,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
IndustrialEconomicType,
|
|
36
|
+
}
|