PageSourceSearch

https://www.ekmd.de/assetm/controllers/routing_redirect_controller-997fb7ac0a06a96eb454047fa5910858.js

js ekmd.de collected 2026-10-09 22:40:01 UTC 2,071 bytes, 76 lines download raw bytes

1import { Controller } from '@hotwired/stimulus'
2
3/* stimulusFetch: 'lazy' */
4export default class extends Controller {
5  connect() {
6    const me = this
7    me.element.addEventListener('routingButtonClicked', me.showPopup.bind(me))
8  }
9
10  disconnect() {
11    const me = this
12    me.element.removeEventListener('routingButtonClicked', me.showPopup.bind(me))
13  }
14
15  showPopup({ detail }) {
16    const map = detail.map
17    const marker = detail.marker
18    const latLng = marker.getLatLng()
19
20    const content = `
21      <div data-controller="routing-redirect">
22        <div class="text-center">
23          <h6 class="fw-bold mb-2 text-dark">Navigation starten</h6>
24          <p class="mb-3 small">
25            Mit Google Maps zu diesem Ort navigieren.
26            Dabei verlassen Sie unsere Webseite und öffnen einen externen Dienst.
27          </p>
28          <button type="button"
29            class="btn btn-primary btn-sm"
30            data-action="routing-redirect#redirectToGoogleMaps"
31            data-lat="${latLng.lat}"
32            data-lng="${latLng.lng}">
33            <i class="fa-solid fa-diamond-turn-right"></i>
34            Routenplanung starten
35          </button>
36        </div>
37      </div>
38    `
39
40    marker.bindPopup(content, {
41      maxWidth: 225,
42      offset: [0, -25],
43      keepInView: true
44    }).openPopup()
45
46    marker.on('popupclose', function(e) {
47      map.panTo(marker.getLatLng())
48    })
49
50    map.setView(latLng)
51  }
52
53  redirectToGoogleMaps(event) {
54    const lat = event.target.getAttribute('data-lat')
55    const lng = event.target.getAttribute('data-lng')
56
57    if ( !lat || !lng ) {
58      return
59    }
60
61    const userAgent = navigator.userAgent.toLowerCase()
62
63    if ( /iphone|ipod|ipad/.test(userAgent) ) {
64      window.location.href = `https://maps.apple.com/?daddr=${lat},${lng}`
65    }
66    else if ( /android/.test(userAgent) ) {
67      window.location.href = `google.navigation:q=${lat},${lng}`
68    }
69    else {
70      window.open(
71        `https://www.google.com/maps/dir/?api=1&destination=${lat},${lng}`,
72        '_blank'
73      )
74    }
75  }
76}

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.