Skip to content

Commit

Permalink
Force translate geolocate control label
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislav-chynoransky committed Nov 8, 2024
1 parent 4f3b201 commit 4d5cbd7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resources/js/components/MapContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ onUnmounted(() => {
resizeObserver.value.disconnect();
});
const onGeolocateControlLoaded = (ctrlGeolocate) => {
const ctrlGeolocateIcon = ctrlGeolocate.querySelector(
'.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon',
);
if (ctrlGeolocate) ctrlGeolocate.setAttribute('aria-label', 'Lokalizuj ma');
if (ctrlGeolocateIcon)
ctrlGeolocateIcon.setAttribute('title', 'Lokalizuj ma');
};
const loaded = ([{ data }, map]) => {
map.addSource('artworks', {
type: 'geojson',
Expand Down Expand Up @@ -120,6 +130,17 @@ const loaded = ([{ data }, map]) => {
)
.addControl(new mapboxgl.GeolocateControl(), 'top-right');
const checkGeolocateControlLoaded = () => {
const el = document.querySelector('.mapboxgl-ctrl-geolocate');
if (el) {
onGeolocateControlLoaded(el);
} else {
setTimeout(checkGeolocateControlLoaded, 100);
}
};
checkGeolocateControlLoaded();
map.scrollZoom.disable();
mapRef.value = map;
observeResize(map);
Expand Down

0 comments on commit 4d5cbd7

Please sign in to comment.