af-mobile-client-vue3 1.2.25 → 1.2.26

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.
@@ -1,172 +1,133 @@
1
- <script setup lang="ts">
2
- import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
3
- import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
4
- import {
5
- Button as VanButton,
6
- Tab as VanTab,
7
- Tabs as VanTabs,
8
- } from 'vant'
9
- import { defineEmits, defineProps, onBeforeMount, ref, watch, useSlots, computed } from 'vue'
10
-
11
- const props = withDefaults(defineProps<{
12
- configName?: string
13
- serviceName?: string
14
- groupFormData?: object
15
- mode?: string
16
- }>(), {
17
- configName: '',
18
- serviceName: undefined,
19
- groupFormData: () => ({}),
20
- mode: '查询',
21
- })
22
- const emit = defineEmits(['submit'])
23
-
24
- interface Form {
25
- configName?: string
26
- serviceName?: string
27
- groupFormData?: object
28
- mode?: string
29
- }
30
-
31
- const groupItems = ref([])
32
- const formData = ref({})
33
- const submitGroup = ref(false)
34
- const submitSimple = ref(false)
35
- const isInit = ref(false)
36
- const initStatus = ref(false)
37
- const propsData = ref<Partial<Form>>({})
38
-
39
- const slots = useSlots()
40
- const renderableGroupItems = computed(() => {
41
- return groupItems.value.filter(item => {
42
- if (item.formGroupType === 'slot') {
43
- return !!(item.slotName && slots[item.slotName])
44
- }
45
- return true
46
- })
47
- })
48
-
49
- // 组件初始化函数
50
- function init(params: Form) {
51
- initStatus.value = true
52
- propsData.value = {
53
- configName: props.configName,
54
- serviceName: props.serviceName,
55
- groupFormData: props.groupFormData,
56
- mode: props.mode,
57
- ...params,
58
- }
59
- formData.value = propsData.value.groupFormData
60
- getConfigByName(propsData.value.configName, (result) => {
61
- console.log('result===', result)
62
- if (result?.groups) {
63
- groupItems.value = result.groups
64
- result.groups.forEach((group) => {
65
- if (!formData.value[group.groupName])
66
- formData.value[group.groupName] = {}
67
- if (group.showSubmitBtn)
68
- submitGroup.value = true
69
- })
70
- }
71
- else {
72
- submitSimple.value = result.showSubmitBtn
73
- groupItems.value = [{ ...result }]
74
- }
75
- isInit.value = true
76
- }, propsData.value.serviceName)
77
- }
78
- watch(() => props.groupFormData, (_val) => {
79
- formData.value = { ...formData.value, ...props.groupFormData }
80
- })
81
- onBeforeMount(() => {
82
- if (!initStatus.value)
83
- init(props)
84
- })
85
- interface XFormLike {
86
- validate: () => Promise<void>
87
- formGroupName?: string
88
- form?: any
89
- getFormData?: () => object
90
- }
91
- const xFormListRef = ref<XFormLike[]>([])
92
-
93
- // 注册表单实例,避免重复
94
- function setRef(refValue: XFormLike) {
95
- if (refValue && !xFormListRef.value.includes(refValue)) {
96
- xFormListRef.value.push(refValue)
97
- }
98
- }
99
- // 注销表单实例
100
- function removeRef(refValue: XFormLike) {
101
- const idx = xFormListRef.value.indexOf(refValue)
102
- if (idx !== -1) xFormListRef.value.splice(idx, 1)
103
- }
104
-
105
- async function submit() {
106
- for (const res of xFormListRef.value) {
107
- try {
108
- await res.validate()
109
- if (res.formGroupName && res.form) {
110
- formData.value[res.formGroupName] = res.form
111
- } else if (typeof res.getFormData === 'function') {
112
- Object.assign(formData.value, res.getFormData())
113
- }
114
- } catch (msg) {
115
- console.log('error:', msg)
116
- return
117
- }
118
- }
119
- console.log('formData.value===', formData.value)
120
- emit('submit', formData.value)
121
- }
122
-
123
- defineExpose({ init, removeRef, xFormListRef })
124
- </script>
125
-
126
- <template>
127
- <div v-if="isInit" id="x-form-group">
128
- <VanTabs scrollspy sticky>
129
- <VanTab
130
- v-for="(item, index) in renderableGroupItems"
131
- :key="item.groupName ? (item.groupName + index) : index"
132
- :title="item.describe ? item.describe : item.tableName "
133
- >
134
- <div class="x-form-group-item">
135
- <template v-if="item.formGroupType === 'slot'">
136
- <slot :name="item.slotName"
137
- :item="item"
138
- :form-data="item.groupName ? formData[item.groupName] : formData"
139
- :set-ref="setRef"
140
- :remove-ref="removeRef"
141
- />
142
- </template>
143
- <template v-else>
144
- <XForm
145
- ref="xFormListRef"
146
- :mode="props.mode"
147
- :group-form-items="item"
148
- :form-data="item.groupName ? formData[item.groupName] : formData"
149
- :form-name="item.groupName"
150
- :service-name="props.serviceName"
151
- :submit-button="submitSimple"
152
- @on-submit="submit"
153
- />
154
- </template>
155
- </div>
156
- </VanTab>
157
- </VanTabs>
158
- <VanButton v-if="submitGroup" round block type="primary" @click="submit">
159
- 提交
160
- </VanButton>
161
- </div>
162
- </template>
163
-
164
- <style scoped lang="less">
165
- #x-form-group {
166
- background-color: rgb(247, 248, 250);
167
- padding-bottom: 10px;
168
- .x-form-group-item {
169
- margin: 20px 0;
170
- }
171
- }
172
- </style>
1
+ <script setup lang="ts">
2
+ import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
3
+ import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
4
+ import {
5
+ Button as VanButton,
6
+ Tab as VanTab,
7
+ Tabs as VanTabs,
8
+ } from 'vant'
9
+ import { defineEmits, defineProps, onBeforeMount, ref, watch } from 'vue'
10
+
11
+ const props = withDefaults(defineProps<{
12
+ configName?: string
13
+ serviceName?: string
14
+ groupFormData?: object
15
+ mode?: string
16
+ }>(), {
17
+ configName: '',
18
+ serviceName: undefined,
19
+ groupFormData: () => ({}),
20
+ mode: '查询',
21
+ })
22
+ const emit = defineEmits(['submit'])
23
+
24
+ interface Form {
25
+ configName?: string
26
+ serviceName?: string
27
+ groupFormData?: object
28
+ mode?: string
29
+ }
30
+
31
+ const groupItems = ref([])
32
+ const formData = ref({})
33
+ const submitGroup = ref(false)
34
+ const submitSimple = ref(false)
35
+ const isInit = ref(false)
36
+ const initStatus = ref(false)
37
+ const propsData = ref({})
38
+
39
+ // 组件初始化函数
40
+ function init(params: Form) {
41
+ initStatus.value = true
42
+ propsData.value = {
43
+ // configName: '',
44
+ // serviceName: undefined,
45
+ // groupFormData: () => ({}),
46
+ // mode: '查询',
47
+ configName: props.configName,
48
+ serviceName: props.serviceName,
49
+ groupFormData: props.groupFormData,
50
+ mode: props.mode,
51
+ ...params,
52
+ }
53
+ formData.value = propsData.value.groupFormData
54
+ getConfigByName(propsData.value.configName, (result) => {
55
+ if (result?.groups) {
56
+ // submitGroup.value = true
57
+ groupItems.value = result.groups
58
+ result.groups.forEach((group) => {
59
+ if (!formData.value[group.groupName])
60
+ formData.value[group.groupName] = {}
61
+ if (group.showSubmitBtn)
62
+ submitGroup.value = true
63
+ })
64
+ }
65
+ else {
66
+ submitSimple.value = result.showSubmitBtn
67
+ groupItems.value = [{ ...result }]
68
+ }
69
+ isInit.value = true
70
+ }, propsData.value.serviceName)
71
+ }
72
+ watch(() => props.groupFormData, (_val) => {
73
+ formData.value = { ...formData.value, ...props.groupFormData }
74
+ })
75
+ onBeforeMount(() => {
76
+ if (!initStatus.value)
77
+ init(props)
78
+ })
79
+ const xFormListRef = ref([])
80
+ async function submit() {
81
+ for (const res of xFormListRef.value) {
82
+ await res.validate()
83
+ formData.value[res.formGroupName] = res.form
84
+ }
85
+ emit('submit', formData.value)
86
+ }
87
+
88
+ // function initXForm(index: number) {
89
+ // 获取自身示例
90
+ // refs[`xFormListRef-${index}`].init({})
91
+ // }
92
+
93
+ defineExpose({ init })
94
+ </script>
95
+
96
+ <template>
97
+ <div v-if="isInit" id="x-form-group">
98
+ <VanTabs scrollspy sticky>
99
+ <VanTab
100
+ v-for="(item, index) in groupItems"
101
+ :key="item.groupName ? (item.groupName + index) : index"
102
+ :title="item.describe ? item.describe : item.tableName "
103
+ >
104
+ <div class="x-form-group-item">
105
+ <!-- :ref="`xFormListRef-${index}`" -->
106
+ <XForm
107
+ ref="xFormListRef"
108
+ :mode="props.mode"
109
+ :group-form-items="item"
110
+ :form-data="item.groupName ? formData[item.groupName] : formData"
111
+ :form-name="item.groupName"
112
+ :service-name="props.serviceName"
113
+ :submit-button="submitSimple"
114
+ @on-submit="submit"
115
+ />
116
+ </div>
117
+ </VanTab>
118
+ </VanTabs>
119
+ <VanButton v-if="submitGroup" round block type="primary" @click="submit">
120
+ 提交
121
+ </VanButton>
122
+ </div>
123
+ </template>
124
+
125
+ <style scoped lang="less">
126
+ #x-form-group {
127
+ background-color: rgb(247, 248, 250);
128
+ padding-bottom: 10px;
129
+ .x-form-group-item {
130
+ margin: 20px 0;
131
+ }
132
+ }
133
+ </style>
@@ -1,154 +1,154 @@
1
- // 导入proj控件
2
- import * as proj from 'ol/proj'
3
-
4
- function forEachPoint(func) {
5
- return function (input, opt_output, opt_dimension) {
6
- const len = input.length
7
-
8
- const dimension = opt_dimension || 2
9
- let output
10
-
11
- if (opt_output) {
12
- output = opt_output
13
- }
14
- else {
15
- if (dimension !== 2) {
16
- output = input.slice()
17
- }
18
- else {
19
- output = [len]
20
- }
21
- }
22
- for (let offset = 0; offset < len; offset += dimension) {
23
- func(input, output, offset)
24
- }
25
- return output
26
- }
27
- }
28
-
29
- const gcj02 = {}
30
- const PI = Math.PI
31
- const AXIS = 6378245.0
32
- // eslint-disable-next-line no-loss-of-precision
33
- const OFFSET = 0.00669342162296594323 // (a^2 - b^2) / a^2
34
-
35
- function delta(wgLon, wgLat) {
36
- let dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
37
- let dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
38
- const radLat = (wgLat / 180.0) * PI
39
- let magic = Math.sin(radLat)
40
- magic = 1 - OFFSET * magic * magic
41
- const sqrtMagic = Math.sqrt(magic)
42
- dLat = (dLat * 180.0) / (((AXIS * (1 - OFFSET)) / (magic * sqrtMagic)) * PI)
43
- dLon = (dLon * 180.0) / ((AXIS / sqrtMagic) * Math.cos(radLat) * PI)
44
- return [dLon, dLat]
45
- }
46
-
47
- function outOfChina(lon, lat) {
48
- if (lon < 72.004 || lon > 137.8347) {
49
- return true
50
- }
51
- return lat < 0.8293 || lat > 55.8271
52
- }
53
-
54
- function transformLat(x, y) {
55
- let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
56
- ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
57
- ret += ((20.0 * Math.sin(y * PI) + 40.0 * Math.sin((y / 3.0) * PI)) * 2.0) / 3.0
58
- ret += ((160.0 * Math.sin((y / 12.0) * PI) + 320 * Math.sin((y * PI) / 30.0)) * 2.0) / 3.0
59
- return ret
60
- }
61
-
62
- function transformLon(x, y) {
63
- let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
64
- ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
65
- ret += ((20.0 * Math.sin(x * PI) + 40.0 * Math.sin((x / 3.0) * PI)) * 2.0) / 3.0
66
- ret += ((150.0 * Math.sin((x / 12.0) * PI) + 300.0 * Math.sin((x / 30.0) * PI)) * 2.0) / 3.0
67
- return ret
68
- }
69
-
70
- gcj02.toWGS84 = forEachPoint((input, output, offset) => {
71
- let lng = input[offset]
72
- let lat = input[offset + 1]
73
- if (!outOfChina(lng, lat)) {
74
- const deltaD = delta(lng, lat)
75
- lng = lng - deltaD[0] // 改回减法
76
- lat = lat - deltaD[1] // 改回减法
77
- }
78
- output[offset] = lng
79
- output[offset + 1] = lat
80
- })
81
-
82
- gcj02.fromWGS84 = forEachPoint((input, output, offset) => {
83
- let lng = input[offset]
84
- let lat = input[offset + 1]
85
- if (!outOfChina(lng, lat)) {
86
- const deltaD = delta(lng, lat)
87
- lng = lng + deltaD[0] // 改回加法
88
- lat = lat + deltaD[1] // 改回加法
89
- }
90
- output[offset] = lng
91
- output[offset + 1] = lat
92
- })
93
-
94
- const sphericalMercator = {}
95
- const RADIUS = 6378137
96
- const MAX_LATITUDE = 85.0511287798
97
- const RAD_PER_DEG = Math.PI / 180
98
-
99
- sphericalMercator.forward = forEachPoint((input, output, offset) => {
100
- const lat = Math.max(Math.min(MAX_LATITUDE, input[offset + 1]), -MAX_LATITUDE)
101
- const sin = Math.sin(lat * RAD_PER_DEG)
102
- output[offset] = RADIUS * input[offset] * RAD_PER_DEG
103
- output[offset + 1] = (RADIUS * Math.log((1 + sin) / (1 - sin))) / 2
104
- })
105
-
106
- sphericalMercator.inverse = forEachPoint((input, output, offset) => {
107
- output[offset] = input[offset] / RADIUS / RAD_PER_DEG
108
- output[offset + 1] = (2 * Math.atan(Math.exp(input[offset + 1] / RADIUS)) - Math.PI / 2) / RAD_PER_DEG
109
- })
110
-
111
- const projzh = {}
112
-
113
- projzh.ll2gmerc = function (input, opt_output, opt_dimension) {
114
- const output = gcj02.toWGS84(input, opt_output, opt_dimension) // 改用 toWGS84
115
- return projzh.ll2smerc(output, output, opt_dimension)
116
- }
117
-
118
- projzh.gmerc2ll = function (input, opt_output, opt_dimension) {
119
- const output = projzh.smerc2ll(input, input, opt_dimension)
120
- return gcj02.fromWGS84(output, opt_output, opt_dimension) // 改用 fromWGS84
121
- }
122
-
123
- // smerc2gmerc 需要修改
124
-
125
- projzh.smerc2gmerc = function (input, opt_output, opt_dimension) {
126
- let output = projzh.smerc2ll(input, input, opt_dimension)
127
- output = gcj02.toWGS84(output, output, opt_dimension) // 这里应该用 toWGS84
128
- return projzh.ll2smerc(output, output, opt_dimension)
129
- }
130
-
131
- // gmerc2smerc 需要修改
132
-
133
- projzh.gmerc2smerc = function (input, opt_output, opt_dimension) {
134
- let output = projzh.smerc2ll(input, input, opt_dimension)
135
- output = gcj02.fromWGS84(output, output, opt_dimension) // 这里应该用 fromWGS84
136
- return projzh.ll2smerc(output, output, opt_dimension)
137
- }
138
-
139
- projzh.ll2smerc = sphericalMercator.forward
140
- projzh.smerc2ll = sphericalMercator.inverse
141
-
142
- // 定义WGS84转GCJ02的投影
143
- const extent = [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]
144
- export const wgs84ToGcj02Projection = new proj.Projection({
145
- code: 'WGS84-TO-GCJ02',
146
- extent,
147
- units: 'm',
148
- })
149
-
150
- // 添加投影和转换方法
151
- proj.addProjection(wgs84ToGcj02Projection)
152
- // 注意这里转换方法的顺序与原来相反
153
- proj.addCoordinateTransforms('EPSG:4326', wgs84ToGcj02Projection, projzh.ll2gmerc, projzh.gmerc2ll)
154
- proj.addCoordinateTransforms('EPSG:3857', wgs84ToGcj02Projection, projzh.smerc2gmerc, projzh.gmerc2smerc)
1
+ // 导入proj控件
2
+ import * as proj from 'ol/proj'
3
+
4
+ function forEachPoint(func) {
5
+ return function (input, opt_output, opt_dimension) {
6
+ const len = input.length
7
+
8
+ const dimension = opt_dimension || 2
9
+ let output
10
+
11
+ if (opt_output) {
12
+ output = opt_output
13
+ }
14
+ else {
15
+ if (dimension !== 2) {
16
+ output = input.slice()
17
+ }
18
+ else {
19
+ output = [len]
20
+ }
21
+ }
22
+ for (let offset = 0; offset < len; offset += dimension) {
23
+ func(input, output, offset)
24
+ }
25
+ return output
26
+ }
27
+ }
28
+
29
+ const gcj02 = {}
30
+ const PI = Math.PI
31
+ const AXIS = 6378245.0
32
+ // eslint-disable-next-line no-loss-of-precision
33
+ const OFFSET = 0.00669342162296594323 // (a^2 - b^2) / a^2
34
+
35
+ function delta(wgLon, wgLat) {
36
+ let dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
37
+ let dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
38
+ const radLat = (wgLat / 180.0) * PI
39
+ let magic = Math.sin(radLat)
40
+ magic = 1 - OFFSET * magic * magic
41
+ const sqrtMagic = Math.sqrt(magic)
42
+ dLat = (dLat * 180.0) / (((AXIS * (1 - OFFSET)) / (magic * sqrtMagic)) * PI)
43
+ dLon = (dLon * 180.0) / ((AXIS / sqrtMagic) * Math.cos(radLat) * PI)
44
+ return [dLon, dLat]
45
+ }
46
+
47
+ function outOfChina(lon, lat) {
48
+ if (lon < 72.004 || lon > 137.8347) {
49
+ return true
50
+ }
51
+ return lat < 0.8293 || lat > 55.8271
52
+ }
53
+
54
+ function transformLat(x, y) {
55
+ let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
56
+ ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
57
+ ret += ((20.0 * Math.sin(y * PI) + 40.0 * Math.sin((y / 3.0) * PI)) * 2.0) / 3.0
58
+ ret += ((160.0 * Math.sin((y / 12.0) * PI) + 320 * Math.sin((y * PI) / 30.0)) * 2.0) / 3.0
59
+ return ret
60
+ }
61
+
62
+ function transformLon(x, y) {
63
+ let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
64
+ ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
65
+ ret += ((20.0 * Math.sin(x * PI) + 40.0 * Math.sin((x / 3.0) * PI)) * 2.0) / 3.0
66
+ ret += ((150.0 * Math.sin((x / 12.0) * PI) + 300.0 * Math.sin((x / 30.0) * PI)) * 2.0) / 3.0
67
+ return ret
68
+ }
69
+
70
+ gcj02.toWGS84 = forEachPoint((input, output, offset) => {
71
+ let lng = input[offset]
72
+ let lat = input[offset + 1]
73
+ if (!outOfChina(lng, lat)) {
74
+ const deltaD = delta(lng, lat)
75
+ lng = lng - deltaD[0] // 改回减法
76
+ lat = lat - deltaD[1] // 改回减法
77
+ }
78
+ output[offset] = lng
79
+ output[offset + 1] = lat
80
+ })
81
+
82
+ gcj02.fromWGS84 = forEachPoint((input, output, offset) => {
83
+ let lng = input[offset]
84
+ let lat = input[offset + 1]
85
+ if (!outOfChina(lng, lat)) {
86
+ const deltaD = delta(lng, lat)
87
+ lng = lng + deltaD[0] // 改回加法
88
+ lat = lat + deltaD[1] // 改回加法
89
+ }
90
+ output[offset] = lng
91
+ output[offset + 1] = lat
92
+ })
93
+
94
+ const sphericalMercator = {}
95
+ const RADIUS = 6378137
96
+ const MAX_LATITUDE = 85.0511287798
97
+ const RAD_PER_DEG = Math.PI / 180
98
+
99
+ sphericalMercator.forward = forEachPoint((input, output, offset) => {
100
+ const lat = Math.max(Math.min(MAX_LATITUDE, input[offset + 1]), -MAX_LATITUDE)
101
+ const sin = Math.sin(lat * RAD_PER_DEG)
102
+ output[offset] = RADIUS * input[offset] * RAD_PER_DEG
103
+ output[offset + 1] = (RADIUS * Math.log((1 + sin) / (1 - sin))) / 2
104
+ })
105
+
106
+ sphericalMercator.inverse = forEachPoint((input, output, offset) => {
107
+ output[offset] = input[offset] / RADIUS / RAD_PER_DEG
108
+ output[offset + 1] = (2 * Math.atan(Math.exp(input[offset + 1] / RADIUS)) - Math.PI / 2) / RAD_PER_DEG
109
+ })
110
+
111
+ const projzh = {}
112
+
113
+ projzh.ll2gmerc = function (input, opt_output, opt_dimension) {
114
+ const output = gcj02.toWGS84(input, opt_output, opt_dimension) // 改用 toWGS84
115
+ return projzh.ll2smerc(output, output, opt_dimension)
116
+ }
117
+
118
+ projzh.gmerc2ll = function (input, opt_output, opt_dimension) {
119
+ const output = projzh.smerc2ll(input, input, opt_dimension)
120
+ return gcj02.fromWGS84(output, opt_output, opt_dimension) // 改用 fromWGS84
121
+ }
122
+
123
+ // smerc2gmerc 需要修改
124
+
125
+ projzh.smerc2gmerc = function (input, opt_output, opt_dimension) {
126
+ let output = projzh.smerc2ll(input, input, opt_dimension)
127
+ output = gcj02.toWGS84(output, output, opt_dimension) // 这里应该用 toWGS84
128
+ return projzh.ll2smerc(output, output, opt_dimension)
129
+ }
130
+
131
+ // gmerc2smerc 需要修改
132
+
133
+ projzh.gmerc2smerc = function (input, opt_output, opt_dimension) {
134
+ let output = projzh.smerc2ll(input, input, opt_dimension)
135
+ output = gcj02.fromWGS84(output, output, opt_dimension) // 这里应该用 fromWGS84
136
+ return projzh.ll2smerc(output, output, opt_dimension)
137
+ }
138
+
139
+ projzh.ll2smerc = sphericalMercator.forward
140
+ projzh.smerc2ll = sphericalMercator.inverse
141
+
142
+ // 定义WGS84转GCJ02的投影
143
+ const extent = [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]
144
+ export const wgs84ToGcj02Projection = new proj.Projection({
145
+ code: 'WGS84-TO-GCJ02',
146
+ extent,
147
+ units: 'm',
148
+ })
149
+
150
+ // 添加投影和转换方法
151
+ proj.addProjection(wgs84ToGcj02Projection)
152
+ // 注意这里转换方法的顺序与原来相反
153
+ proj.addCoordinateTransforms('EPSG:4326', wgs84ToGcj02Projection, projzh.ll2gmerc, projzh.gmerc2ll)
154
+ proj.addCoordinateTransforms('EPSG:3857', wgs84ToGcj02Projection, projzh.smerc2gmerc, projzh.gmerc2smerc)