waibu-maps 1.0.6 → 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/bajoTemplate/template/wmaps.js +23 -23
- package/package.json +1 -1
- package/waibuBootstrap/theme/component/factory/control-attribution.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-buttons.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-draw.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-fullscreen.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-geolocate.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-group-menu.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-group.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-image.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-loader.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-logo.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-mouse-pos.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-navigation.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-ruler.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-scale.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-search.js +1 -1
- package/waibuBootstrap/theme/component/factory/control-zbp.js +1 -1
- package/waibuBootstrap/theme/component/factory/control.js +1 -1
- package/waibuBootstrap/theme/component/factory/layer-geojson.js +1 -1
- package/waibuBootstrap/theme/component/factory/layer-html-cluster.js +1 -1
- package/waibuBootstrap/theme/component/factory/map.js +1 -1
- package/waibuBootstrap/theme/component/factory/script.js +1 -1
- /package/{bajo → plugin}/.alias +0 -0
- /package/{bajo → plugin}/.dependencies +0 -0
- /package/{bajo → plugin}/config.json +0 -0
|
@@ -9,7 +9,7 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
9
9
|
this.popup = null
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async
|
|
12
|
+
handleClusterClick = async (layerId, clusterId = 'cluster_id') => {
|
|
13
13
|
this.handlePointer(layerId)
|
|
14
14
|
this.map.on('click', layerId, async (e) => {
|
|
15
15
|
const features = this.map.queryRenderedFeatures(e.point, {
|
|
@@ -25,14 +25,14 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async
|
|
28
|
+
createPopupHtml = async ({ props, handler, coordinates, layerId }, evt) => {
|
|
29
29
|
let html = _.isString(handler) ? handler : undefined
|
|
30
30
|
if (_.isFunction(handler)) html = await handler.call(this, { props, coordinates, layerId }, evt)
|
|
31
31
|
if (!html) html = props.name ?? props.title ?? props.description ?? ''
|
|
32
32
|
return html
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
getEventCoordinates (evt) {
|
|
35
|
+
getEventCoordinates = (evt) => {
|
|
36
36
|
let coordinates = evt.features[0].geometry.coordinates.slice()
|
|
37
37
|
if (_.isArray(coordinates[0])) {
|
|
38
38
|
const centroid = turf.centroid(evt.features[0])
|
|
@@ -44,14 +44,14 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
44
44
|
return coordinates
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
async
|
|
47
|
+
extractPopup = async ({ evt, layerId, handler, props, coordinates }) => {
|
|
48
48
|
props = props ?? evt.features[0].properties
|
|
49
49
|
coordinates = coordinates ?? this.getEventCoordinates(evt)
|
|
50
50
|
const html = await this.createPopupHtml({ props, handler, coordinates, layerId }, evt)
|
|
51
51
|
return { props, coordinates, html }
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
createPopup () {
|
|
54
|
+
createPopup = () => {
|
|
55
55
|
if (!this.popup) {
|
|
56
56
|
this.popup = new maplibregl.Popup({
|
|
57
57
|
closeButton: false,
|
|
@@ -61,7 +61,7 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
61
61
|
return this.popup
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
async
|
|
64
|
+
handleNonClusterClick = async (layerId, handler = 'name') => {
|
|
65
65
|
if (handler === true) handler = 'name'
|
|
66
66
|
this.handlePointer(layerId)
|
|
67
67
|
this.map.on('click', layerId, async evt => {
|
|
@@ -81,14 +81,14 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
81
81
|
})
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
popup ({ layerId, props, html, coordinates }) {
|
|
84
|
+
popup = ({ layerId, props, html, coordinates }) => {
|
|
85
85
|
return new maplibregl.Popup({ className: 'popup-layer-' + layerId + ' popup-target-' + props.id })
|
|
86
86
|
.setLngLat(coordinates)
|
|
87
87
|
.setHTML(html)
|
|
88
88
|
.addTo(this.map)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
updateClusterMarkers ({ sourceId, clusterKey = 'cluster', clusterIdKey = 'clusterId', handler }) {
|
|
91
|
+
updateClusterMarkers = ({ sourceId, clusterKey = 'cluster', clusterIdKey = 'clusterId', handler }) => {
|
|
92
92
|
if (!handler) return
|
|
93
93
|
const newMarkers = {}
|
|
94
94
|
const features = this.map.querySourceFeatures(sourceId)
|
|
@@ -116,7 +116,7 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
116
116
|
this.markersOnScreen = newMarkers
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
handlePointer (layerId) {
|
|
119
|
+
handlePointer = (layerId) => {
|
|
120
120
|
this.map.on('mouseenter', layerId, () => {
|
|
121
121
|
this.map.getCanvas().style.cursor = 'pointer'
|
|
122
122
|
})
|
|
@@ -125,11 +125,11 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
125
125
|
})
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
closePopup () {
|
|
128
|
+
closePopup = () => {
|
|
129
129
|
if (this.popup) this.popup.remove()
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
async
|
|
132
|
+
loadImage = async (src) => {
|
|
133
133
|
if (_.isString(src)) {
|
|
134
134
|
const [url, id] = src.split(';')
|
|
135
135
|
src = { url, id }
|
|
@@ -140,7 +140,7 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
140
140
|
this.map.addImage(src.id, image.data)
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
async
|
|
143
|
+
loadImages = async (sources, fetch = true) => {
|
|
144
144
|
for (const src of sources) {
|
|
145
145
|
if (fetch) {
|
|
146
146
|
const data = await wmpa.fetchApi(src)
|
|
@@ -152,7 +152,7 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
async
|
|
155
|
+
createControl = async (options = {}) => {
|
|
156
156
|
const ctrl = new WaibuMapsControl(options)
|
|
157
157
|
ctrl.scope = this.scope
|
|
158
158
|
if (options.builder) {
|
|
@@ -169,7 +169,7 @@ class WaibuMaps { // eslint-disable-line no-unused-vars
|
|
|
169
169
|
return ctrl
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
async
|
|
172
|
+
createControlNative = async (className, options = {}) => {
|
|
173
173
|
const name = wmpa.pascalCase(className)
|
|
174
174
|
const ctrl = new maplibregl[name](options)
|
|
175
175
|
let type = options.classSelector
|
|
@@ -210,7 +210,7 @@ class WaibuMapsUtil {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
decToDms (decimal, opts = {}) {
|
|
213
|
+
decToDms = (decimal, opts = {}) => {
|
|
214
214
|
if (opts === true || opts === false) opts = { isLng: opts }
|
|
215
215
|
opts.north = opts.north ?? 'N'
|
|
216
216
|
opts.south = opts.south ?? 'S'
|
|
@@ -221,19 +221,19 @@ class WaibuMapsUtil {
|
|
|
221
221
|
else return result + ' ' + (decimal >= 0 ? opts.north : opts.south)
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
getSourceId (id, ext) {
|
|
224
|
+
getSourceId = (id, ext) => {
|
|
225
225
|
return 's-' + _.kebabCase(id) + (_.isEmpty(ext) ? '' : ('-' + ext))
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
getLayerId (id, ext = '') {
|
|
228
|
+
getLayerId = (id, ext = '') => {
|
|
229
229
|
return 'l-' + _.kebabCase(id) + (_.isEmpty(ext) ? '' : ('-' + ext))
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
getSourceLayerIds (id, ext) {
|
|
232
|
+
getSourceLayerIds = (id, ext) => {
|
|
233
233
|
return [this.getSourceId(id, ext), this.getLayerId(id, ext)]
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
srcAsStyle (src) {
|
|
236
|
+
srcAsStyle = (src) => {
|
|
237
237
|
if ((_.isPlainObject(src) && src.version && src.sources)) return src
|
|
238
238
|
const result = {}
|
|
239
239
|
if (_.isString(src)) {
|
|
@@ -265,7 +265,7 @@ class WaibuMapsControl { // eslint-disable-line no-unused-vars
|
|
|
265
265
|
this.class = options.class
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
createControl () {
|
|
268
|
+
createControl = () => {
|
|
269
269
|
this.container = document.createElement('div')
|
|
270
270
|
// this.container.setAttribute('oncontextmenu', 'return false')
|
|
271
271
|
this.container.classList.add('maplibregl-ctrl', 'maplibregl-ctrl-wmaps')
|
|
@@ -289,19 +289,19 @@ class WaibuMapsControl { // eslint-disable-line no-unused-vars
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
onAdd (map) {
|
|
292
|
+
onAdd = (map) => {
|
|
293
293
|
this.map = map
|
|
294
294
|
this.createControl()
|
|
295
295
|
return this.container
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
onRemove () {
|
|
298
|
+
onRemove = () => {
|
|
299
299
|
this.container.parentNode.removeChild(this.container)
|
|
300
300
|
this.map = undefined
|
|
301
301
|
this.scope = undefined
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
getDefaultPosition () {
|
|
304
|
+
getDefaultPosition = () => {
|
|
305
305
|
return this.position
|
|
306
306
|
}
|
|
307
307
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ async function controlButtons () {
|
|
|
19
19
|
this.params.noTag = true
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async
|
|
22
|
+
build = async () => {
|
|
23
23
|
const { generateId } = this.plugin.app.bajo
|
|
24
24
|
const { routePath } = this.plugin.app.waibu
|
|
25
25
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
@@ -14,7 +14,7 @@ async function controlDraw () {
|
|
|
14
14
|
this.params.noTag = true
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async
|
|
17
|
+
build = async () => {
|
|
18
18
|
const { isString } = this.plugin.app.bajo.lib._
|
|
19
19
|
const opts = {}
|
|
20
20
|
if (['imperial', 'metric', 'nautical'].includes(this.params.attr.unit)) opts.unit = this.params.attr.unit
|
|
@@ -11,7 +11,7 @@ async function controlGroupMenu () {
|
|
|
11
11
|
this.params.attr.class.push('dropdown', 'dropstart')
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async
|
|
14
|
+
build = async () => {
|
|
15
15
|
const { $ } = this.component
|
|
16
16
|
const { fastGlob } = this.plugin.app.bajo.lib
|
|
17
17
|
const { isString } = this.plugin.app.bajo.lib._
|
|
@@ -10,7 +10,7 @@ async function controlGroup () {
|
|
|
10
10
|
this.params.noTag = true
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async
|
|
13
|
+
build = async () => {
|
|
14
14
|
const { generateId } = this.plugin.app.bajo
|
|
15
15
|
const { jsonStringify, minify } = this.plugin.app.waibuMpa
|
|
16
16
|
const { isString, trim } = this.plugin.app.bajo.lib._
|
|
@@ -10,7 +10,7 @@ async function controlImage () {
|
|
|
10
10
|
this.params.noTag = true
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async
|
|
13
|
+
build = async () => {
|
|
14
14
|
const { routePath } = this.plugin.app.waibu
|
|
15
15
|
const { jsonStringify, groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
|
|
16
16
|
const { isString, isEmpty } = this.plugin.app.bajo.lib._
|
|
@@ -9,7 +9,7 @@ async function controlLoader () {
|
|
|
9
9
|
this.params.noTag = true
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async
|
|
12
|
+
build = async () => {
|
|
13
13
|
const { groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
|
|
14
14
|
const group = groupAttrs(this.params.attr, ['progress'])
|
|
15
15
|
const attr = group.progress ?? {}
|
|
@@ -11,7 +11,7 @@ async function controlLogo () {
|
|
|
11
11
|
this.params.noTag = true
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async
|
|
14
|
+
build = async () => {
|
|
15
15
|
const { fs, fastGlob } = this.plugin.app.bajo.lib
|
|
16
16
|
const { routePath } = this.plugin.app.waibu
|
|
17
17
|
const { jsonStringify, groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
|
|
@@ -11,7 +11,7 @@ async function controlMousePos () {
|
|
|
11
11
|
this.params.noTag = true
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async
|
|
14
|
+
build = async () => {
|
|
15
15
|
const { generateId } = this.plugin.app.bajo
|
|
16
16
|
const { jsonStringify, minify } = this.plugin.app.waibuMpa
|
|
17
17
|
const { has, omit } = this.plugin.app.bajo.lib._
|
|
@@ -9,7 +9,7 @@ async function controlNavigation () {
|
|
|
9
9
|
this.params.noTag = true
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async
|
|
12
|
+
build = async () => {
|
|
13
13
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
14
14
|
const opts = { showCompass: false }
|
|
15
15
|
if (this.params.attr.compass) opts.showCompass = true
|
|
@@ -21,7 +21,7 @@ async function controlRuler () {
|
|
|
21
21
|
this.params.noTag = true
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async
|
|
24
|
+
build = async () => {
|
|
25
25
|
const { routePath } = this.plugin.app.waibu
|
|
26
26
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
27
27
|
const pos = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'bottom-right'
|
|
@@ -10,7 +10,7 @@ async function controlSearch () {
|
|
|
10
10
|
this.params.noTag = true
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async
|
|
13
|
+
build = async () => {
|
|
14
14
|
const { generateId } = this.plugin.app.bajo
|
|
15
15
|
const { isString } = this.plugin.app.bajo.lib._
|
|
16
16
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
@@ -11,7 +11,7 @@ async function controlZbp () {
|
|
|
11
11
|
this.params.noTag = true
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async
|
|
14
|
+
build = async () => {
|
|
15
15
|
const { generateId } = this.plugin.app.bajo
|
|
16
16
|
const { jsonStringify, minify } = this.plugin.app.waibuMpa
|
|
17
17
|
const { omit } = this.plugin.app.bajo.lib._
|
|
@@ -75,7 +75,7 @@ async function layerGeojson () {
|
|
|
75
75
|
this.params.noTag = true
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
async
|
|
78
|
+
build = async () => {
|
|
79
79
|
const { generateId } = this.plugin.app.bajo
|
|
80
80
|
const { isString } = this.plugin.app.bajo.lib._
|
|
81
81
|
const { groupAttrs } = this.plugin.app.waibuMpa
|
|
@@ -63,7 +63,7 @@ async function layerHtmlCluster () {
|
|
|
63
63
|
this.params.noTag = true
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
async
|
|
66
|
+
build = async () => {
|
|
67
67
|
const { generateId } = this.plugin.app.bajo
|
|
68
68
|
const { attrToArray, jsonStringify } = this.plugin.app.waibuMpa
|
|
69
69
|
const { fetch, routePath } = this.plugin.app.waibu
|
|
@@ -19,7 +19,7 @@ async function map () {
|
|
|
19
19
|
this.readBlock()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async
|
|
22
|
+
build = async () => {
|
|
23
23
|
const { generateId } = this.plugin.app.bajo
|
|
24
24
|
const { without, omit, isString } = this.plugin.app.bajo.lib._
|
|
25
25
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
@@ -9,7 +9,7 @@ async function script () {
|
|
|
9
9
|
this.params.noTag = true
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async
|
|
12
|
+
build = async () => {
|
|
13
13
|
const type = WmapsBase.blockTypes.includes(this.params.attr.type) ? this.params.attr.type : 'run'
|
|
14
14
|
this.block[type].push(this.params.html)
|
|
15
15
|
this.params.html = this.writeBlock()
|
/package/{bajo → plugin}/.alias
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|