Skip to content

Commit 90bd437

Browse files
committed
CS
1 parent b982ece commit 90bd437

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

resources/js/public/map-popup.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ export default () => {
4040
event.stopPropagation();
4141
}
4242
};
43-
this.containerDiv.addEventListener('contextmenu', allowAnchorRightClicksHandler);
43+
this.containerDiv.addEventListener(
44+
'contextmenu',
45+
allowAnchorRightClicksHandler,
46+
);
4447
}
4548

4649
/** Called when the popup is added to the map. */
@@ -57,10 +60,15 @@ export default () => {
5760

5861
/** Called each frame when the popup needs to draw itself. */
5962
draw() {
60-
const divPosition = this.getProjection().fromLatLngToDivPixel(this.position)!;
63+
const divPosition = this.getProjection().fromLatLngToDivPixel(
64+
this.position,
65+
)!;
6166

6267
// Hide the popup when it is far out of view.
63-
const display = Math.abs(divPosition.x) < 4000 && Math.abs(divPosition.y) < 4000 ? 'block' : 'none';
68+
const display =
69+
Math.abs(divPosition.x) < 4000 && Math.abs(divPosition.y) < 4000
70+
? 'block'
71+
: 'none';
6472

6573
if (display === 'block') {
6674
this.containerDiv.style.left = divPosition.x + 'px';

resources/js/public/map.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
declare var google: any;
22
import styles from './map-styles';
33
import getMarkerPopup from './map-popup';
4-
import { MarkerClusterer, SuperClusterAlgorithm } from '@googlemaps/markerclusterer';
4+
import {
5+
MarkerClusterer,
6+
SuperClusterAlgorithm,
7+
} from '@googlemaps/markerclusterer';
58

69
export default async (): Promise<void> => {
710
const mapElement = document.getElementById('map') as HTMLElement,
@@ -15,13 +18,16 @@ export default async (): Promise<void> => {
1518
places: any[] = [],
1619
markers: google.maps.marker = [];
1720
const infoWindow = new google.maps.InfoWindow();
18-
const map = new google.maps.Map(document.getElementById('map') as HTMLElement, {
19-
mapTypeId: 'roadmap',
20-
zoom: 12,
21-
mapTypeControl: false,
22-
streetViewControl: false,
23-
styles,
24-
});
21+
const map = new google.maps.Map(
22+
document.getElementById('map') as HTMLElement,
23+
{
24+
mapTypeId: 'roadmap',
25+
zoom: 12,
26+
mapTypeControl: false,
27+
streetViewControl: false,
28+
styles,
29+
},
30+
);
2531

2632
try {
2733
const response = await fetch(apiUrl, {
@@ -38,7 +44,11 @@ export default async (): Promise<void> => {
3844
const buildContent = ({ place }: { place: any }): string => {
3945
let coords = [];
4046
let htmlString = '<div class="popup-bubble-content">';
41-
htmlString += place.image ? '<img class="popup-bubble-content-image" src="/storage/' + place.image.path + '" height="40" alt="">' : '';
47+
htmlString += place.image
48+
? '<img class="popup-bubble-content-image" src="/storage/' +
49+
place.image.path +
50+
'" height="40" alt="">'
51+
: '';
4252
htmlString += '<h3 class="popup-bubble-content-title">';
4353
htmlString += place.title[locale];
4454
htmlString += '</h3>';
@@ -49,7 +59,10 @@ export default async (): Promise<void> => {
4959
htmlString += coords.join('<br>');
5060
htmlString += '</div>';
5161
if (!noButton) {
52-
htmlString += '<a class="popup-bubble-content-button" href="' + place.url + '">';
62+
htmlString +=
63+
'<a class="popup-bubble-content-button" href="' +
64+
place.url +
65+
'">';
5366
htmlString += buttonLabel ?? 'More info';
5467
htmlString += '</a>';
5568
}

0 commit comments

Comments
 (0)