waibu-maps 1.2.5 → 1.2.7

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,16 +1,16 @@
1
1
  import path from 'path'
2
2
 
3
3
  async function icon () {
4
- const { map, camelCase } = this.lib._
4
+ const { map } = this.lib._
5
5
  if (!this.app.waibuStatic) return []
6
6
  const icons = await this.app.waibuStatic.listResources(`${this.name}.asset:/icon`)
7
7
  return map(icons, icon => {
8
8
  const base = path.basename(icon.href)
9
9
  const dir = path.dirname(icon.href)
10
- const name = camelCase(`${path.basename(dir)} ${base}`)
10
+ const id = `icon:/${path.basename(dir)}/${base}`
11
11
  return {
12
- id: icon.href,
13
- name
12
+ id,
13
+ url: icon.href
14
14
  }
15
15
  })
16
16
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "connection": "memory",
3
+ "properties": [
4
+ "id::255:primary:true",
5
+ "name::255:true"
6
+ ]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-maps",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Maps for Waibu MPA",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@ async function controlNavigation () {
11
11
 
12
12
  build = async () => {
13
13
  const { jsonStringify } = this.plugin.app.waibuMpa
14
- const opts = { showCompass: false }
14
+ const opts = { showCompass: true }
15
15
  if (this.params.attr.compass) opts.showCompass = true
16
16
  if (this.params.attr.noZoom) opts.showZoom = false
17
17
  if (this.params.attr.visualizePitch) opts.visualizePitch = true
@@ -19,7 +19,15 @@ async function controlNavigation () {
19
19
  opts.classGroup = true
20
20
  opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'bottom-right'
21
21
  this.addBlock('control', `
22
- await wmaps.createControlNative('NavigationControl', ${jsonStringify(opts, true)})
22
+ const navOpts = ${jsonStringify(opts, true)}
23
+ if (Alpine.store('map').noMapRotate) {
24
+ map.dragRotate.disable()
25
+ map.touchZoomRotate.disableRotation()
26
+ navOpts.showCompass = false
27
+ } else {
28
+ if (Alpine.store('map').hideCompass) navOpts.showCompass = false
29
+ }
30
+ await wmaps.createControlNative('NavigationControl', navOpts)
23
31
  `)
24
32
  this.params.html = this.writeBlock()
25
33
  }
@@ -62,7 +62,7 @@ async function controlSearch () {
62
62
  feeds.unshift({ code: 'latLng', name: 'gotoLatLng', feed: { id: 'latLng', label: 'latLng' } })
63
63
  this.$store.mapSearch.feeds = feeds
64
64
  const body = feeds.map(feed => '<c:dropdown-item :class="$store.mapSearch.feed === $el.getAttribute(\\'data-code-feedid\\') ? \\'active\\' : \\'\\'" data-code-feedid="' + feed.code + ':' + feed.feed.id + '" t:content="' + feed.feed.label + '" @click="$store.mapSearch.feed = \\'' + feed.code + ':' + feed.feed.id + '\\'"/>')
65
- await wmpa.addComponent(body, '#${id} .input-group .dropdown-menu', 'div')
65
+ await wmpa.addComponent(body, '#${id} .input-group .dropdown-menu', 'div', true)
66
66
  if (!this.$store.mapSearch.feed) this.$store.mapSearch.feed = feeds[0].code + ':' + feeds[0].feed.id
67
67
  const html = this.$store.mapSearch.recent ?? ''
68
68
  wmpa.replaceWithComponentHtml(html, '#${id} .result div', 'div')
@@ -68,6 +68,7 @@ async function map () {
68
68
  ${(this.block.mapStyle ?? []).join('\n')}
69
69
  },
70
70
  async onMissingImage (evt) {
71
+ if (evt.id.startsWith('icon:')) await wmaps.loadIcon(evt.id)
71
72
  ${(this.block.missingImage ?? []).join('\n')}
72
73
  },
73
74
  onLayerVisibility (layerId, shown) {
@@ -117,6 +118,7 @@ async function map () {
117
118
  measure: Alpine.$persist('nautical').as('mapMeasure'),
118
119
  zoomScrollCenter: Alpine.$persist(false).as('mapZoomScrollCenter'),
119
120
  noMapRotate: Alpine.$persist(false).as('mapNoMapRotate'),
121
+ hideCompass: Alpine.$persist(false).as('mapHideCompass'),
120
122
  center: Alpine.$persist(null).as('mapCenter'),
121
123
  zoom: Alpine.$persist(null).as('mapZoom'),
122
124
  bearing: Alpine.$persist(null).as('mapBearing'),
@@ -0,0 +1,71 @@
1
+ import wmapsBase from '../wmaps-base.js'
2
+
3
+ async function modalMisc () {
4
+ const SmapsBase = await wmapsBase.call(this)
5
+
6
+ return class SmapsModalMisc extends SmapsBase {
7
+ constructor (options) {
8
+ super(options)
9
+ this.params.noTag = true
10
+ }
11
+
12
+ build = async () => {
13
+ this.params.html = await this.component.buildSentence(`
14
+ <c:modal id="${this.params.attr.id}" t:title="generalSettings" x-data="{
15
+ measure: $store.map.measure,
16
+ degree: $store.map.degree,
17
+ zoomScrollCenter: $store.map.zoomScrollCenter,
18
+ noMapRotate: $store.map.noMapRotate,
19
+ hideCompass: $store.map.hideCompass,
20
+ submit () {
21
+ $store.map.measure = this.measure
22
+ $store.map.degree = this.degree
23
+ $store.map.zoomScrollCenter = this.zoomScrollCenter
24
+ $store.map.noMapRotate = this.noMapRotate
25
+ $store.map.hideCompass = this.hideCompass
26
+ window.location.reload()
27
+ },
28
+ toggleNoMapRotate (val) {
29
+ if (val) {
30
+ $refs.hideCompass.setAttribute('disabled', '')
31
+ this.hideCompass = false
32
+ } else {
33
+ $refs.hideCompass.removeAttribute('disabled')
34
+ }
35
+ }
36
+ }" x-init="
37
+ toggleNoMapRotate($store.map.noMapRotate)
38
+ $watch('noMapRotate', val => toggleNoMapRotate(val))
39
+ ">
40
+ <c:grid-row>
41
+ <c:grid-col col="6-md">
42
+ <c:fieldset t:legend="measurement" legend-type="6" margin="bottom-3">
43
+ <c:form-radio t:label="nautical" value="nautical" x-model="measure" />
44
+ <c:form-radio t:label="imperial" value="imperial" x-model="measure" />
45
+ <c:form-radio t:label="metric" value="metric" x-model="measure" />
46
+ </c:fieldset>
47
+ </c:grid-col>
48
+ <c:grid-col col="6-md">
49
+ <c:fieldset t:legend="degreeFormat" legend-type="6" margin="bottom-3">
50
+ <c:form-radio t:label="degreeMinuteSecond" value="DMS" x-model="degree" />
51
+ <c:form-radio t:label="decimalDegree" value="DD" x-model="degree" />
52
+ </c:fieldset>
53
+ </c:grid-col>
54
+ <c:grid-col col="12">
55
+ <c:fieldset t:legend="misc" legend-type="6">
56
+ <c:form-check t:label="zoomScrollFromCenter" value="false" x-model="zoomScrollCenter" />
57
+ <c:form-check t:label="disableMapRotation" value="false" x-model="noMapRotate" />
58
+ <c:form-check t:label="hideCompass" value="false" x-model="hideCompass" x-ref="hideCompass"/>
59
+ </c:fieldset>
60
+ </c:grid-col>
61
+ </c:grid-row>
62
+ <c:div flex="justify-content:end" margin="top-3">
63
+ <c:btn color="primary" t:content="apply" @click="submit()"/>
64
+ </c:div>
65
+ </c:modal>
66
+ `)
67
+ }
68
+ }
69
+ }
70
+
71
+ export default modalMisc
@@ -0,0 +1,3 @@
1
+ {
2
+ "model": "WmapsIcon"
3
+ }