use @ for imports
This commit is contained in:
4
bun.lock
4
bun.lock
@@ -13,6 +13,10 @@
|
||||
"netlify-cli": "^23.13.5",
|
||||
"vite": "^7.3.1",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.0.10",
|
||||
"typescript": "^5.9.3",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
|
||||
11190
package-lock.json
generated
Normal file
11190
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,5 +8,9 @@
|
||||
"modern-normalize": "^3.0.1",
|
||||
"netlify-cli": "^23.13.5",
|
||||
"vite": "^7.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.0.10",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
});
|
||||
};
|
||||
28
tsconfig.json
Normal file
28
tsconfig.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "preserve",
|
||||
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import path from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
lucide: "lucide/dist/esm/lucide/src/lucide.js",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user