Skip to content

Commit

Permalink
feat: map fullscreen control & m/ft scale
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Nov 27, 2023
1 parent 9f50f97 commit bd8e5d3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
},
"devDependencies": {
"@types/leaflet": "^1.9.8",
"@types/leaflet-fullscreen": "^1.0.9",
"@types/webextension-polyfill": "^0.10.6",
"@vitest/coverage-v8": "^0.34.6",
"leaflet-fullscreen": "^1.0.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.1.0",
"release-it": "^17.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/styles/map.css" />
<link rel="stylesheet" href="/leaflet.css" />
<link rel="stylesheet" href="/leaflet.fullscreen.css" />
<title>Leaflet Map</title>
</head>

Expand Down
8 changes: 7 additions & 1 deletion src/map/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import L from 'leaflet';
import 'leaflet-fullscreen';

import { readPB, readQ, type MapData } from './utils/read';
import { type TileType, tileTypes } from './utils/parsePB';
Expand Down Expand Up @@ -44,7 +45,8 @@ if (params.has(gZoom)) {
}

const map: L.Map = L.map('map', {
scrollWheelZoom: false, // TODO: on pc allow ctrl + scroll
fullscreenControl: true,
scrollWheelZoom: true, // TODO: on pc allow ctrl + scroll
zoom: mapData.zoom ?? 17,
zoomSnap: 0.1,
zoomDelta: 0.5,
Expand All @@ -71,3 +73,7 @@ L.tileLayer(tileProviders[mapData.tile || tileTypes[0]].layer, {
maxZoom: 19,
attribution: tileProviders[mapData.tile || tileTypes[0]].attr,
}).addTo(map);

L.control.scale().addTo(map);
// TODO: fix layer loading
//L.control.layers({}, {}, { hideSingleBase: true }).addTo(map)
8 changes: 8 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export default defineConfig({
src: normalizePath(resolve(__dirname, 'node_modules/leaflet/dist/images')),
dest: '.',
},
{
src: normalizePath(resolve(__dirname, 'node_modules/leaflet-fullscreen/dist/leaflet.fullscreen.css')),
dest: '.',
},
{
src: normalizePath(resolve(__dirname, 'node_modules/leaflet-fullscreen/dist/*.png')),
dest: '.',
},
{
src: normalizePath(resolve(__dirname, 'LICENSE')),
dest: '.',
Expand Down

0 comments on commit bd8e5d3

Please sign in to comment.