waibu-maps 1.1.3 → 1.1.4
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,7 +1,7 @@
|
|
|
1
1
|
/* global maplibregl, geolib, _, wmpa, WorkerTimers, turf, Alpine */
|
|
2
2
|
|
|
3
3
|
class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
4
|
-
constructor (map, scope) {
|
|
4
|
+
constructor (map, scope, opts = {}) {
|
|
5
5
|
this.map = map
|
|
6
6
|
this.scope = scope
|
|
7
7
|
this.markers = {}
|
|
@@ -210,6 +210,11 @@ class WaibuMapsUtil {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
setMap = (map, projection) => {
|
|
214
|
+
this.map = map
|
|
215
|
+
if (projection) this.defStyle.projection = projection
|
|
216
|
+
}
|
|
217
|
+
|
|
213
218
|
decToDms = (decimal, opts = {}) => {
|
|
214
219
|
if (opts === true || opts === false) opts = { isLng: opts }
|
|
215
220
|
opts.north = opts.north ?? 'N'
|
package/package.json
CHANGED
|
@@ -23,12 +23,12 @@ async function control () {
|
|
|
23
23
|
Alpine.store('mapControl', {
|
|
24
24
|
attrib: Alpine.$persist(true).as('mapControlAttrib'),
|
|
25
25
|
centerPos: Alpine.$persist(true).as('mapControlCenterPos'),
|
|
26
|
-
fullscreen: Alpine.$persist(
|
|
27
|
-
mousePos: Alpine.$persist(
|
|
26
|
+
fullscreen: Alpine.$persist(false).as('mapControlFullscreen'),
|
|
27
|
+
mousePos: Alpine.$persist(false).as('mapControlMousePos'),
|
|
28
28
|
nav: Alpine.$persist(true).as('mapControlNav'),
|
|
29
|
-
globe: Alpine.$persist(true).as('mapControlGlobe'),
|
|
30
|
-
scale: Alpine.$persist(
|
|
31
|
-
geolocate: Alpine.$persist(
|
|
29
|
+
// globe: Alpine.$persist(true).as('mapControlGlobe'),
|
|
30
|
+
scale: Alpine.$persist(false).as('mapControlScale'),
|
|
31
|
+
geolocate: Alpine.$persist(false).as('mapControlGeolocate'),
|
|
32
32
|
ruler: Alpine.$persist(true).as('mapControlRuler'),
|
|
33
33
|
search: Alpine.$persist(true).as('mapControlSearch')
|
|
34
34
|
})
|
|
@@ -31,6 +31,7 @@ async function map () {
|
|
|
31
31
|
this.params.attr['x-data'] = this.params.attr.id
|
|
32
32
|
this.params.attr['@keyup'] = 'onKeyup'
|
|
33
33
|
const mapOptions = await options.call(this, this.params)
|
|
34
|
+
const projection = this.params.attr.projection ?? 'mercator'
|
|
34
35
|
this.block.reactive.push(`
|
|
35
36
|
async windowLoad () {
|
|
36
37
|
const mapOpts = ${jsonStringify(mapOptions, true)}
|
|
@@ -44,6 +45,7 @@ async function map () {
|
|
|
44
45
|
Alpine.data('${this.params.attr.id}', () => {
|
|
45
46
|
let map
|
|
46
47
|
let wmaps
|
|
48
|
+
let projection = { type: '${projection}' }
|
|
47
49
|
${this.block.nonReactive.join('\n')}
|
|
48
50
|
return {
|
|
49
51
|
init () {
|
|
@@ -63,6 +65,7 @@ async function map () {
|
|
|
63
65
|
this.onMapStyle()
|
|
64
66
|
},
|
|
65
67
|
async onMapStyle () {
|
|
68
|
+
map.setProjection(projection)
|
|
66
69
|
${this.block.mapStyle.join('\n')}
|
|
67
70
|
},
|
|
68
71
|
async onMissingImage (evt) {
|
|
@@ -85,6 +88,7 @@ async function map () {
|
|
|
85
88
|
},
|
|
86
89
|
async run (instance) {
|
|
87
90
|
map = instance
|
|
91
|
+
wmapsUtil.setMap(map, projection)
|
|
88
92
|
wmaps = new WaibuMaps(instance, this)
|
|
89
93
|
map.on('moveend', evt => {
|
|
90
94
|
Alpine.store('map').center = evt.target.getCenter().toArray()
|
|
@@ -22,7 +22,8 @@ async function wmapsBase () {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
static controls = ['csrc', 'navigation-control', 'crlr', 'scale-control', 'attribution-control',
|
|
25
|
-
'fullscreen-control', 'geolocate-control', 'czbp', 'cmp', 'globe-control']
|
|
25
|
+
// 'fullscreen-control', 'geolocate-control', 'czbp', 'cmp', 'globe-control']
|
|
26
|
+
'fullscreen-control', 'geolocate-control', 'czbp', 'cmp']
|
|
26
27
|
|
|
27
28
|
async getWmapsTemplate (html, type, defEmpty = '') {
|
|
28
29
|
const { trim, isEmpty } = this.plugin.app.bajo.lib._
|