use @ for imports
This commit is contained in:
3
src/constants.ts
Normal file
3
src/constants.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const MAP_STYLE = "019be805-c88e-7c8b-9850-bc704d72e604";
|
||||
export const API_KEY = "8nmgHEIZQiIgqQj3RZNa";
|
||||
export const INITIAL_ZOOM = 17;
|
||||
31
src/main.ts
31
src/main.ts
@@ -1,11 +1,18 @@
|
||||
// STYLES
|
||||
import "modern-normalize/modern-normalize.css";
|
||||
import "@fontsource-variable/jetbrains-mono";
|
||||
import "./main.css";
|
||||
import "@/main.css";
|
||||
import "@maptiler/sdk/dist/maptiler-sdk.css";
|
||||
|
||||
// LIBRARIES
|
||||
import $ from "jquery";
|
||||
import { FilterSpecification, Map, config } from "@maptiler/sdk";
|
||||
import { createIcons, Locate, LocateFixed } from "lucide";
|
||||
import { LAYERS } from "./layers";
|
||||
|
||||
// PROJECT
|
||||
import { LAYERS } from "@/layers";
|
||||
import { API_KEY, MAP_STYLE } from "@/constants";
|
||||
import { panToCurrentLocation } from "@/utilities/geo";
|
||||
|
||||
createIcons({
|
||||
icons: {
|
||||
@@ -14,10 +21,6 @@ createIcons({
|
||||
},
|
||||
});
|
||||
|
||||
const MAP_STYLE = "019be805-c88e-7c8b-9850-bc704d72e604";
|
||||
const API_KEY = "8nmgHEIZQiIgqQj3RZNa";
|
||||
const INITIAL_ZOOM = 17;
|
||||
|
||||
config.apiKey = API_KEY;
|
||||
|
||||
const $info = $("#layer");
|
||||
@@ -33,13 +36,7 @@ const map = new Map({
|
||||
|
||||
$("#locate").on("click", (e) => {
|
||||
e.preventDefault();
|
||||
navigator.geolocation.getCurrentPosition((position) => {
|
||||
map.setZoom(INITIAL_ZOOM);
|
||||
map.panTo({
|
||||
lat: position.coords.latitude,
|
||||
lng: position.coords.longitude,
|
||||
});
|
||||
});
|
||||
panToCurrentLocation(map);
|
||||
});
|
||||
|
||||
// Funzione helper per settare i filtri dei layer.
|
||||
@@ -126,10 +123,4 @@ map.on("load", () => {
|
||||
});
|
||||
});
|
||||
|
||||
navigator.geolocation.getCurrentPosition((position) => {
|
||||
map.setZoom(INITIAL_ZOOM);
|
||||
map.panTo({
|
||||
lat: position.coords.latitude,
|
||||
lng: position.coords.longitude,
|
||||
});
|
||||
});
|
||||
panToCurrentLocation(map);
|
||||
|
||||
12
src/utilities/geo.ts
Normal file
12
src/utilities/geo.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Map } from "@maptiler/sdk";
|
||||
import { INITIAL_ZOOM } from "@/constants";
|
||||
|
||||
export const panToCurrentLocation = (map: Map) => {
|
||||
navigator.geolocation.getCurrentPosition((position) => {
|
||||
map.setZoom(INITIAL_ZOOM);
|
||||
map.panTo({
|
||||
lat: position.coords.latitude,
|
||||
lng: position.coords.longitude,
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user