v-ol-map 1.0.13 → 1.1.0
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/.eslintrc.cjs +20 -0
- package/counter.js +9 -0
- package/index.html +13 -0
- package/javascript.svg +1 -0
- package/jsconfig.json +9 -0
- package/lib/ol-map.es.js +2709 -1742
- package/lib/ol-map.umd.js +2 -2
- package/package.json +10 -19
- package/public/vite.svg +1 -0
- package/src/App.vue +46 -0
- package/src/components/index.js +25 -0
- package/src/components/layers/BaseLayer.vue +59 -0
- package/src/components/layers/tile/index.js +7 -0
- package/src/components/layers/tile/index.vue +308 -0
- package/src/components/map/index.js +7 -0
- package/src/components/map/index.vue +194 -0
- package/src/main.js +10 -0
- package/src/utils/cityMap.js +2255 -0
- package/src/utils/index.js +103 -0
- package/src/utils/projConvert.js +320 -0
- package/style.css +97 -0
- package/vite.config.js +32 -0
- package/README.md +0 -16
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import 'ol/ol.css'
|
|
2
|
+
import { Map, View } from 'ol'
|
|
3
|
+
import { defaults as defaultInteraction } from 'ol/interaction'
|
|
4
|
+
import { defaults as defaultControls } from 'ol/control'
|
|
5
|
+
import { getCenterByCity } from '@/utils/cityMap.js'
|
|
6
|
+
import projzh from '@/utils/projConvert'
|
|
7
|
+
import { addCoordinateTransforms, addProjection, Projection } from 'ol/proj.js'
|
|
8
|
+
import { applyTransform } from 'ol/extent.js'
|
|
9
|
+
|
|
10
|
+
const e = function (t, r, s, i, a, n) {
|
|
11
|
+
t.getSource()._forEachFeatureAtCoordinate && t.getSource()._forEachFeatureAtCoordinate(r, s,
|
|
12
|
+
function (e) {
|
|
13
|
+
return i(e, t)
|
|
14
|
+
},
|
|
15
|
+
a, n)
|
|
16
|
+
}
|
|
17
|
+
Map.prototype.forEachSmFeatureAtPixel = function (t, r, s, i) {
|
|
18
|
+
const a = s && s.layerFilter
|
|
19
|
+
? s.layerFilter
|
|
20
|
+
: function () {
|
|
21
|
+
return !0
|
|
22
|
+
}
|
|
23
|
+
const n = this.getLayers().getArray()
|
|
24
|
+
const o = this.getView().getResolution()
|
|
25
|
+
const l = this.getCoordinateFromPixel(t)
|
|
26
|
+
for (let ss = 0; ss < n.length; ss++) {
|
|
27
|
+
const h = n[ss]
|
|
28
|
+
// console.log(h)
|
|
29
|
+
// eslint-disable-next-line no-useless-call
|
|
30
|
+
h.getVisible() && a.call(null, h) && e(h, l, o, r, t, i)
|
|
31
|
+
}
|
|
32
|
+
return this.forEachFeatureAtPixel(t, r, s)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 注册百度坐标系
|
|
36
|
+
const baiduMercatorProj = new Projection({
|
|
37
|
+
code: 'baidu',
|
|
38
|
+
// extent: applyTransform(extent, projzh.ll2bmerc),
|
|
39
|
+
units: 'm'
|
|
40
|
+
})
|
|
41
|
+
addProjection(baiduMercatorProj)
|
|
42
|
+
addCoordinateTransforms('EPSG:4326', baiduMercatorProj, projzh.ll2bmerc, projzh.bmerc2ll)
|
|
43
|
+
addCoordinateTransforms('EPSG:3857', baiduMercatorProj, projzh.smerc2bmerc, projzh.bmerc2smerc)
|
|
44
|
+
// 注册高德坐标系
|
|
45
|
+
const AMapMercatorProj = new Projection({
|
|
46
|
+
code: 'GCJ02',
|
|
47
|
+
extent: applyTransform([-180, -90, 180, 90], projzh.ll2gcj02mc),
|
|
48
|
+
units: 'm'
|
|
49
|
+
})
|
|
50
|
+
addProjection(AMapMercatorProj)
|
|
51
|
+
addCoordinateTransforms('EPSG:4326', AMapMercatorProj, projzh.ll2gcj02mc, projzh.gcj02mc2ll)
|
|
52
|
+
addCoordinateTransforms('EPSG:3857', AMapMercatorProj, projzh.mc2gcj02mc, projzh.gcj02mc2mc)
|
|
53
|
+
|
|
54
|
+
export const validObjKey = (obj, key) => {
|
|
55
|
+
if (obj && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
+
return obj[key] && (Object.keys(obj[key]).length > 0 || typeof obj[key] === 'function')
|
|
57
|
+
} else {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const panTo = (map, center, zoom) => {
|
|
63
|
+
map.getView().animate({ center }, { zoom })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class OlMap {
|
|
67
|
+
static map = OlMap
|
|
68
|
+
constructor (option = {}) {
|
|
69
|
+
// view
|
|
70
|
+
const viewOptDefault = {
|
|
71
|
+
center: [108.552500, 34.322700],
|
|
72
|
+
zoom: 5,
|
|
73
|
+
constrainResolution: true,
|
|
74
|
+
projection: 'EPSG:4326'
|
|
75
|
+
}
|
|
76
|
+
const viewOption = { ...viewOptDefault, ...option.view }
|
|
77
|
+
if (validObjKey(viewOption, 'city') && viewOption.city) {
|
|
78
|
+
viewOption.center = getCenterByCity(viewOption.city) || viewOption.center || viewOptDefault.center
|
|
79
|
+
}
|
|
80
|
+
const view = new View(viewOption)
|
|
81
|
+
|
|
82
|
+
// controls
|
|
83
|
+
const controlsDefault = {
|
|
84
|
+
zoom: false,
|
|
85
|
+
rotate: false,
|
|
86
|
+
attribution: false
|
|
87
|
+
}
|
|
88
|
+
const controlsOption = { ...controlsDefault, ...option.controls }
|
|
89
|
+
const controls = defaultControls(controlsOption).extend([])
|
|
90
|
+
|
|
91
|
+
// 生成地图
|
|
92
|
+
this.map = new Map({
|
|
93
|
+
target: option.target,
|
|
94
|
+
view,
|
|
95
|
+
controls,
|
|
96
|
+
interactions: defaultInteraction(option.interactions)
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static panTo (center, zoom) {
|
|
101
|
+
return panTo(OlMap.map.map, center, zoom)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
function forEachPoint (func) {
|
|
2
|
+
return function (input, optOutput, optDimension) {
|
|
3
|
+
const len = input.length
|
|
4
|
+
const dimension = optDimension || 2
|
|
5
|
+
let output
|
|
6
|
+
if (optOutput) {
|
|
7
|
+
output = optOutput
|
|
8
|
+
} else {
|
|
9
|
+
if (dimension !== 2) {
|
|
10
|
+
output = input.slice()
|
|
11
|
+
} else {
|
|
12
|
+
output = new Array(len)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
for (let offset = 0; offset < len; offset += dimension) {
|
|
16
|
+
func(input, output, offset)
|
|
17
|
+
}
|
|
18
|
+
return output
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const sphericalMercator = {
|
|
23
|
+
RADIUS: 6378137,
|
|
24
|
+
MAX_LATITUDE: 85.0511287798,
|
|
25
|
+
RAD_PER_DEG: Math.PI / 180,
|
|
26
|
+
forward: forEachPoint(function (input, output, offset) {
|
|
27
|
+
const lat = Math.max(Math.min(sphericalMercator.MAX_LATITUDE, input[offset + 1]), -sphericalMercator.MAX_LATITUDE)
|
|
28
|
+
const sin = Math.sin(lat * sphericalMercator.RAD_PER_DEG)
|
|
29
|
+
|
|
30
|
+
output[offset] = sphericalMercator.RADIUS * input[offset] * sphericalMercator.RAD_PER_DEG
|
|
31
|
+
output[offset + 1] = sphericalMercator.RADIUS * Math.log((1 + sin) / (1 - sin)) / 2
|
|
32
|
+
}),
|
|
33
|
+
inverse: forEachPoint(function (input, output, offset) {
|
|
34
|
+
output[offset] = input[offset] / sphericalMercator.RADIUS / sphericalMercator.RAD_PER_DEG
|
|
35
|
+
output[offset + 1] = (2 * Math.atan(Math.exp(input[offset + 1] / sphericalMercator.RADIUS)) - (Math.PI / 2)) / sphericalMercator.RAD_PER_DEG
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getRange (v, min, max) {
|
|
40
|
+
v = Math.max(v, min)
|
|
41
|
+
v = Math.min(v, max)
|
|
42
|
+
|
|
43
|
+
return v
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getLoop (v, min, max) {
|
|
47
|
+
const d = max - min
|
|
48
|
+
while (v > max) {
|
|
49
|
+
v -= d
|
|
50
|
+
}
|
|
51
|
+
while (v < min) {
|
|
52
|
+
v += d
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return v
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function convertor (input, output, offset, table) {
|
|
59
|
+
const px = input[offset]
|
|
60
|
+
const py = input[offset + 1]
|
|
61
|
+
const x = table[0] + table[1] * Math.abs(px)
|
|
62
|
+
const d = Math.abs(py) / table[9]
|
|
63
|
+
const y = table[2] +
|
|
64
|
+
table[3] *
|
|
65
|
+
d +
|
|
66
|
+
table[4] *
|
|
67
|
+
d *
|
|
68
|
+
d +
|
|
69
|
+
table[5] *
|
|
70
|
+
d *
|
|
71
|
+
d *
|
|
72
|
+
d +
|
|
73
|
+
table[6] *
|
|
74
|
+
d *
|
|
75
|
+
d *
|
|
76
|
+
d *
|
|
77
|
+
d +
|
|
78
|
+
table[7] *
|
|
79
|
+
d *
|
|
80
|
+
d *
|
|
81
|
+
d *
|
|
82
|
+
d *
|
|
83
|
+
d +
|
|
84
|
+
table[8] *
|
|
85
|
+
d *
|
|
86
|
+
d *
|
|
87
|
+
d *
|
|
88
|
+
d *
|
|
89
|
+
d *
|
|
90
|
+
d
|
|
91
|
+
|
|
92
|
+
output[offset] = x * (px < 0 ? -1 : 1)
|
|
93
|
+
output[offset + 1] = y * (py < 0 ? -1 : 1)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const baiduMercator = {
|
|
97
|
+
MCBAND: [12890594.86, 8362377.87,
|
|
98
|
+
5591021, 3481989.83, 1678043.12, 0],
|
|
99
|
+
LLBAND: [75, 60, 45, 30, 15, 0],
|
|
100
|
+
MC2LL: [
|
|
101
|
+
[1.410526172116255e-8, 0.00000898305509648872, -1.9939833816331,
|
|
102
|
+
200.9824383106796, -187.2403703815547, 91.6087516669843,
|
|
103
|
+
-23.38765649603339, 2.57121317296198, -0.03801003308653,
|
|
104
|
+
17337981.2],
|
|
105
|
+
[-7.435856389565537e-9, 0.000008983055097726239,
|
|
106
|
+
-0.78625201886289, 96.32687599759846, -1.85204757529826,
|
|
107
|
+
-59.36935905485877, 47.40033549296737, -16.50741931063887,
|
|
108
|
+
2.28786674699375, 10260144.86],
|
|
109
|
+
[-3.030883460898826e-8, 0.00000898305509983578, 0.30071316287616,
|
|
110
|
+
59.74293618442277, 7.357984074871, -25.38371002664745,
|
|
111
|
+
13.45380521110908, -3.29883767235584, 0.32710905363475,
|
|
112
|
+
6856817.37],
|
|
113
|
+
[-1.981981304930552e-8, 0.000008983055099779535, 0.03278182852591,
|
|
114
|
+
40.31678527705744, 0.65659298677277, -4.44255534477492,
|
|
115
|
+
0.85341911805263, 0.12923347998204, -0.04625736007561,
|
|
116
|
+
4482777.06],
|
|
117
|
+
[3.09191371068437e-9, 0.000008983055096812155, 0.00006995724062,
|
|
118
|
+
23.10934304144901, -0.00023663490511, -0.6321817810242,
|
|
119
|
+
-0.00663494467273, 0.03430082397953, -0.00466043876332,
|
|
120
|
+
2555164.4],
|
|
121
|
+
[2.890871144776878e-9, 0.000008983055095805407, -3.068298e-8,
|
|
122
|
+
7.47137025468032, -0.00000353937994, -0.02145144861037,
|
|
123
|
+
-0.00001234426596, 0.00010322952773, -0.00000323890364,
|
|
124
|
+
826088.5]],
|
|
125
|
+
LL2MC: [
|
|
126
|
+
[-0.0015702102444, 111320.7020616939, 1704480524535203,
|
|
127
|
+
-10338987376042340, 26112667856603880,
|
|
128
|
+
-35149669176653700, 26595700718403920,
|
|
129
|
+
-10725012454188240, 1800819912950474, 82.5],
|
|
130
|
+
[0.0008277824516172526, 111320.7020463578, 647795574.6671607,
|
|
131
|
+
-4082003173.641316, 10774905663.51142, -15171875531.51559,
|
|
132
|
+
12053065338.62167, -5124939663.577472, 913311935.9512032,
|
|
133
|
+
67.5],
|
|
134
|
+
[0.00337398766765, 111320.7020202162, 4481351.045890365,
|
|
135
|
+
-23393751.19931662, 79682215.47186455, -115964993.2797253,
|
|
136
|
+
97236711.15602145, -43661946.33752821, 8477230.501135234,
|
|
137
|
+
52.5],
|
|
138
|
+
[0.00220636496208, 111320.7020209128, 51751.86112841131,
|
|
139
|
+
3796837.749470245, 992013.7397791013, -1221952.21711287,
|
|
140
|
+
1340652.697009075, -620943.6990984312, 144416.9293806241,
|
|
141
|
+
37.5],
|
|
142
|
+
[-0.0003441963504368392, 111320.7020576856, 278.2353980772752,
|
|
143
|
+
2485758.690035394, 6070.750963243378, 54821.18345352118,
|
|
144
|
+
9540.606633304236, -2710.55326746645, 1405.483844121726,
|
|
145
|
+
22.5],
|
|
146
|
+
[-0.0003218135878613132, 111320.7020701615, 0.00369383431289,
|
|
147
|
+
823725.6402795718, 0.46104986909093, 2351.343141331292,
|
|
148
|
+
1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45]],
|
|
149
|
+
forward: forEachPoint(function (input, output, offset) {
|
|
150
|
+
const lng = getLoop(input[offset], -180, 180)
|
|
151
|
+
const lat = getRange(input[offset + 1], -74, 74)
|
|
152
|
+
|
|
153
|
+
let table = null
|
|
154
|
+
let j
|
|
155
|
+
for (j = 0; j < baiduMercator.LLBAND.length; ++j) {
|
|
156
|
+
if (lat >= baiduMercator.LLBAND[j]) {
|
|
157
|
+
table = baiduMercator.LL2MC[j]
|
|
158
|
+
break
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (table === null) {
|
|
162
|
+
for (j = baiduMercator.LLBAND.length - 1; j >= 0; --j) {
|
|
163
|
+
if (lat <= -baiduMercator.LLBAND[j]) {
|
|
164
|
+
table = baiduMercator.LL2MC[j]
|
|
165
|
+
break
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
output[offset] = lng
|
|
170
|
+
output[offset + 1] = lat
|
|
171
|
+
convertor(output, output, offset, table)
|
|
172
|
+
}),
|
|
173
|
+
inverse: forEachPoint(function (input, output, offset) {
|
|
174
|
+
const Y_ABS = Math.abs(input[offset + 1])
|
|
175
|
+
|
|
176
|
+
let table = null
|
|
177
|
+
for (let j = 0; j < baiduMercator.MCBAND.length; j++) {
|
|
178
|
+
if (Y_ABS >= baiduMercator.MCBAND[j]) {
|
|
179
|
+
table = baiduMercator.MC2LL[j]
|
|
180
|
+
break
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
convertor(input, output, offset, table)
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const gcj02 = {
|
|
189
|
+
PI: Math.PI,
|
|
190
|
+
AXIS: 6378245.0,
|
|
191
|
+
// eslint-disable-next-line no-loss-of-precision
|
|
192
|
+
OFFSET: 0.00669342162296594323, // (a^2 - b^2) / a^2
|
|
193
|
+
delta: function (wgLon, wgLat) {
|
|
194
|
+
let dLat = this.transformLat(wgLon - 105.0, wgLat - 35.0)
|
|
195
|
+
let dLon = this.transformLon(wgLon - 105.0, wgLat - 35.0)
|
|
196
|
+
const radLat = wgLat / 180.0 * this.PI
|
|
197
|
+
let magic = Math.sin(radLat)
|
|
198
|
+
magic = 1 - this.OFFSET * magic * magic
|
|
199
|
+
const sqrtMagic = Math.sqrt(magic)
|
|
200
|
+
dLat = (dLat * 180.0) / ((this.AXIS * (1 - this.OFFSET)) / (magic * sqrtMagic) * this.PI)
|
|
201
|
+
dLon = (dLon * 180.0) / (this.AXIS / sqrtMagic * Math.cos(radLat) * this.PI)
|
|
202
|
+
return [dLon, dLat]
|
|
203
|
+
},
|
|
204
|
+
outOfChina: function (lon, lat) {
|
|
205
|
+
if (lon < 72.004 || lon > 137.8347) {
|
|
206
|
+
return true
|
|
207
|
+
}
|
|
208
|
+
return lat < 0.8293 || lat > 55.8271
|
|
209
|
+
},
|
|
210
|
+
transformLat: function (x, y) {
|
|
211
|
+
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))
|
|
212
|
+
ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0
|
|
213
|
+
ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0
|
|
214
|
+
ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0
|
|
215
|
+
return ret
|
|
216
|
+
},
|
|
217
|
+
transformLon: function (x, y) {
|
|
218
|
+
let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
|
|
219
|
+
ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0
|
|
220
|
+
ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0
|
|
221
|
+
ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0
|
|
222
|
+
return ret
|
|
223
|
+
},
|
|
224
|
+
toWGS84: forEachPoint(function (input, output, offset) {
|
|
225
|
+
let lng = input[offset]
|
|
226
|
+
let lat = input[offset + 1]
|
|
227
|
+
if (!gcj02.outOfChina(lng, lat)) {
|
|
228
|
+
const deltaD = gcj02.delta(lng, lat)
|
|
229
|
+
lng = lng - deltaD[0]
|
|
230
|
+
lat = lat - deltaD[1]
|
|
231
|
+
}
|
|
232
|
+
output[offset] = lng
|
|
233
|
+
output[offset + 1] = lat
|
|
234
|
+
}),
|
|
235
|
+
fromWGS84: forEachPoint(function (input, output, offset) {
|
|
236
|
+
let lng = input[offset]
|
|
237
|
+
let lat = input[offset + 1]
|
|
238
|
+
if (!gcj02.outOfChina(lng, lat)) {
|
|
239
|
+
const deltaD = gcj02.delta(lng, lat)
|
|
240
|
+
lng = lng + deltaD[0]
|
|
241
|
+
lat = lat + deltaD[1]
|
|
242
|
+
}
|
|
243
|
+
output[offset] = lng
|
|
244
|
+
output[offset + 1] = lat
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const bd09 = {
|
|
249
|
+
PI: Math.PI,
|
|
250
|
+
X_PI: Math.PI * 3000 / 180,
|
|
251
|
+
toGCJ02: function (input, output, offset) {
|
|
252
|
+
const x = input[offset] - 0.0065
|
|
253
|
+
const y = input[offset + 1] - 0.006
|
|
254
|
+
const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * bd09.X_PI)
|
|
255
|
+
const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * bd09.X_PI)
|
|
256
|
+
output[offset] = z * Math.cos(theta)
|
|
257
|
+
output[offset + 1] = z * Math.sin(theta)
|
|
258
|
+
return output
|
|
259
|
+
},
|
|
260
|
+
fromGCJ02: function (input, output, offset) {
|
|
261
|
+
const x = input[offset]
|
|
262
|
+
const y = input[offset + 1]
|
|
263
|
+
const z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * bd09.X_PI)
|
|
264
|
+
const theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * bd09.X_PI)
|
|
265
|
+
output[offset] = z * Math.cos(theta) + 0.0065
|
|
266
|
+
output[offset + 1] = z * Math.sin(theta) + 0.006
|
|
267
|
+
return output
|
|
268
|
+
},
|
|
269
|
+
toWGS84: function (input, optOutput, optDimension) {
|
|
270
|
+
const output = forEachPoint(bd09.toGCJ02)(input, optOutput, optDimension)
|
|
271
|
+
return gcj02.toWGS84(output, output, optDimension)
|
|
272
|
+
},
|
|
273
|
+
fromWGS84: function (input, optOutput, optDimension) {
|
|
274
|
+
const output = gcj02.fromWGS84(input, optOutput, optDimension)
|
|
275
|
+
return forEachPoint(bd09.fromGCJ02)(output, output, optDimension)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const projzh = {
|
|
280
|
+
smerc2bmerc: function (input, optOutput, optDimension) {
|
|
281
|
+
let output = sphericalMercator.inverse(input, optOutput, optDimension)
|
|
282
|
+
output = bd09.fromWGS84(output, output, optDimension)
|
|
283
|
+
return baiduMercator.forward(output, output, optDimension)
|
|
284
|
+
},
|
|
285
|
+
bmerc2smerc: function (input, optOutput, optDimension) {
|
|
286
|
+
let output = baiduMercator.inverse(input, optOutput, optDimension)
|
|
287
|
+
output = bd09.toWGS84(output, output, optDimension)
|
|
288
|
+
return sphericalMercator.forward(output, output, optDimension)
|
|
289
|
+
},
|
|
290
|
+
bmerc2ll: function (input, optOutput, optDimension) {
|
|
291
|
+
const output = baiduMercator.inverse(input, optOutput, optDimension)
|
|
292
|
+
return bd09.toWGS84(output, output, optDimension)
|
|
293
|
+
},
|
|
294
|
+
ll2bmerc: function (input, optOutput, optDimension) {
|
|
295
|
+
const output = bd09.fromWGS84(input, optOutput, optDimension)
|
|
296
|
+
return baiduMercator.forward(output, output, optDimension)
|
|
297
|
+
},
|
|
298
|
+
mc2gcj02mc: function (input, optOutput, optDimension) {
|
|
299
|
+
let output = sphericalMercator.inverse(input, optOutput, optDimension)
|
|
300
|
+
output = gcj02.fromWGS84(output, output, optDimension)
|
|
301
|
+
return sphericalMercator.forward(output, output, optDimension)
|
|
302
|
+
},
|
|
303
|
+
gcj02mc2mc: function (input, optOutput, optDimension) {
|
|
304
|
+
let output = sphericalMercator.inverse(input, optOutput, optDimension)
|
|
305
|
+
output = gcj02.toWGS84(output, output, optDimension)
|
|
306
|
+
return sphericalMercator.forward(output, output, optDimension)
|
|
307
|
+
},
|
|
308
|
+
gcj02mc2ll: function (input, optOutput, optDimension) {
|
|
309
|
+
const output = sphericalMercator.inverse(input, optOutput, optDimension)
|
|
310
|
+
return gcj02.toWGS84(output, output, optDimension)
|
|
311
|
+
},
|
|
312
|
+
ll2gcj02mc: function (input, optOutput, optDimension) {
|
|
313
|
+
const output = gcj02.fromWGS84(input, optOutput, optDimension)
|
|
314
|
+
return sphericalMercator.forward(output, output, optDimension)
|
|
315
|
+
},
|
|
316
|
+
ll2smerc: sphericalMercator.forward,
|
|
317
|
+
smerc2ll: sphericalMercator.inverse
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export default projzh
|
package/style.css
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
font-size: 16px;
|
|
4
|
+
line-height: 24px;
|
|
5
|
+
font-weight: 400;
|
|
6
|
+
|
|
7
|
+
color-scheme: light dark;
|
|
8
|
+
color: rgba(255, 255, 255, 0.87);
|
|
9
|
+
background-color: #242424;
|
|
10
|
+
|
|
11
|
+
font-synthesis: none;
|
|
12
|
+
text-rendering: optimizeLegibility;
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
-webkit-text-size-adjust: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
a {
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
color: #646cff;
|
|
21
|
+
text-decoration: inherit;
|
|
22
|
+
}
|
|
23
|
+
a:hover {
|
|
24
|
+
color: #535bf2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body {
|
|
28
|
+
margin: 0;
|
|
29
|
+
display: flex;
|
|
30
|
+
place-items: center;
|
|
31
|
+
min-width: 320px;
|
|
32
|
+
min-height: 100vh;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
h1 {
|
|
36
|
+
font-size: 3.2em;
|
|
37
|
+
line-height: 1.1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#app {
|
|
41
|
+
max-width: 1280px;
|
|
42
|
+
margin: 0 auto;
|
|
43
|
+
padding: 2rem;
|
|
44
|
+
text-align: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.logo {
|
|
48
|
+
height: 6em;
|
|
49
|
+
padding: 1.5em;
|
|
50
|
+
will-change: filter;
|
|
51
|
+
}
|
|
52
|
+
.logo:hover {
|
|
53
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
54
|
+
}
|
|
55
|
+
.logo.vanilla:hover {
|
|
56
|
+
filter: drop-shadow(0 0 2em #f7df1eaa);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.card {
|
|
60
|
+
padding: 2em;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.read-the-docs {
|
|
64
|
+
color: #888;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
button {
|
|
68
|
+
border-radius: 8px;
|
|
69
|
+
border: 1px solid transparent;
|
|
70
|
+
padding: 0.6em 1.2em;
|
|
71
|
+
font-size: 1em;
|
|
72
|
+
font-weight: 500;
|
|
73
|
+
font-family: inherit;
|
|
74
|
+
background-color: #1a1a1a;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
transition: border-color 0.25s;
|
|
77
|
+
}
|
|
78
|
+
button:hover {
|
|
79
|
+
border-color: #646cff;
|
|
80
|
+
}
|
|
81
|
+
button:focus,
|
|
82
|
+
button:focus-visible {
|
|
83
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@media (prefers-color-scheme: light) {
|
|
87
|
+
:root {
|
|
88
|
+
color: #213547;
|
|
89
|
+
background-color: #ffffff;
|
|
90
|
+
}
|
|
91
|
+
a:hover {
|
|
92
|
+
color: #747bff;
|
|
93
|
+
}
|
|
94
|
+
button {
|
|
95
|
+
background-color: #f9f9f9;
|
|
96
|
+
}
|
|
97
|
+
}
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { resolve } from 'path'
|
|
2
|
+
import { createVuePlugin } from 'vite-plugin-vue2'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
server: {
|
|
6
|
+
host: 'localhost',
|
|
7
|
+
port: 8080,
|
|
8
|
+
open: true
|
|
9
|
+
},
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@': resolve(__dirname, 'src')
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
plugins: [createVuePlugin()],
|
|
16
|
+
build: {
|
|
17
|
+
outDir: 'lib',
|
|
18
|
+
lib: {
|
|
19
|
+
entry: resolve(__dirname, 'src/components/index.js'),
|
|
20
|
+
name: 'ol-map',
|
|
21
|
+
fileName: (format) => `ol-map.${format}.js`
|
|
22
|
+
},
|
|
23
|
+
rollupOptions: {
|
|
24
|
+
external: ['vue'],
|
|
25
|
+
output: {
|
|
26
|
+
globals: {
|
|
27
|
+
vue: 'Vue'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/README.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Vue 3 + TypeScript + Vite
|
|
2
|
-
|
|
3
|
-
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
|
4
|
-
|
|
5
|
-
## Recommended IDE Setup
|
|
6
|
-
|
|
7
|
-
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
|
|
8
|
-
|
|
9
|
-
## Type Support For `.vue` Imports in TS
|
|
10
|
-
|
|
11
|
-
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
|
|
12
|
-
|
|
13
|
-
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
|
|
14
|
-
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
|
|
15
|
-
|
|
16
|
-
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|