PageSourceSearch

https://www.ekmd.de/assetm/controllers/church_markers_controller-92a5f98d830a4deced676fb73cd27595.js

js ekmd.de collected 2026-10-09 22:39:59 UTC 2,459 bytes, 119 lines download raw bytes

1import LeafletController from './leaflet_controller.js'
2
3/* stimulusFetch: 'lazy' */
4export default class extends LeafletController {
5  static values = {
6    markersUrl: String
7  }
8
9  connect() {
10    const me = this
11    super.connect()
12
13    me.debouncedMapChanged = me.debounce(() => {
14      me.onMapChanged()
15    }, 1000)
16
17    me.map.on('moveend zoomend', me.debouncedMapChanged)
18    me.spinner.show()
19
20    fetch(me.markersUrlValue)
21      .then((response) => response.json())
22      .then((markers) => me.addMarkers(markers))
23      .then(() => me.spinner.hide())
24      .then(() => me.dispatch('loaded'))
25  }
26
27  disconnect() {
28    this.map.off('moveend zoomend', this.debouncedMapChanged)
29  }
30
31  onMapChanged() {
32    const me = this
33    const bounds = me.map.getBounds()
34
35    if ( !me.visibleMarkersChanged(bounds) ) {
36      return
37    }
38
39    me.dispatch('mapZoomedOrMoved', {
40      detail: {
41        bounds:
42          bounds.getSouth() + ',' + bounds.getWest() + ',' +
43          bounds.getNorth() + ',' + bounds.getEast()
44      }
45    })
46  }
47
48  visibleMarkersChanged(bounds) {
49    if ( !bounds.isValid() ) {
50      return false
51    }
52
53    const me = this
54    const len = me.markers.length
55    let marker, visibleMarkers = []
56
57    for ( let i = 0; i < len; i++ ) {
58      marker = me.markers[i]
59
60      if ( bounds.contains(marker.getLatLng()) ) {
61        visibleMarkers.push(marker.options.uuid)
62      }
63    }
64
65    if ( visibleMarkers.sort().toString() !== me.visibleMarkers.toString() ) {
66      me.visibleMarkers = visibleMarkers
67      return true
68    }
69
70    return false
71  }
72
73  processSearchResult({detail}) {
74    const me = this
75    let result = {}
76
77    if ( !detail.selectedValue ) {
78      me.fitBounds(me.bounds)
79      return
80    }
81
82    try {
83      result = JSON.parse(detail.selectedValue)
84    }
85    catch ( e ) {
86    }
87
88    const coords = result.bounds
89
90    if ( coords ) {
91      const bounds = L.latLngBounds(
92        new L.LatLng(coords.s, coords.w),
93        new L.LatLng(coords.n, coords.e)
94      )
95
96      me.fitBounds(bounds)
97
98      if ( me.map.getZoom() > me.detailZoom ) {
99        me.map.setZoom(me.detailZoom)
100      }
101
102      return
103    }
104
105    if ( result.uuid ) {
106      const len = me.markers.length
107      let marker
108
109      for ( let i = 0; i < len; i++ ) {
110        marker = me.markers[i]
111
112        if ( marker.options.uuid === result.uuid ) {
113          me.map.setView(marker.getLatLng(), me.detailZoom)
114          break
115        }
116      }
117    }
118  }
119}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.