Skip to content

Commit

Permalink
Support min/maxzoom in map style
Browse files Browse the repository at this point in the history
  • Loading branch information
keichan34 committed Jun 17, 2024
1 parent cbb1ea9 commit 68307e2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ const App: React.FC = () => {
setSavedState({ z: rawZoom, lat, lng });
});

map.on('styledata', () => {
// style has changed, see if there's any metadata we need to read
const styleMetadata: {
'geolonia:maxzoom'?: number
'geolonia:minzoom'?: number
} = map.getStyle().metadata || {};
const maxzoom = styleMetadata['geolonia:maxzoom'];
if (maxzoom) {
map.setMaxZoom(maxzoom);
} else {
map.setMaxZoom();
}
const minzoom = styleMetadata['geolonia:minzoom'];
if (minzoom) {
map.setMinZoom(minzoom);
} else {
map.setMinZoom();
}
});

// https://github.com/geolonia/embed/issues/270
// Geolonia の Embed API の transformRequest 関数は geolonia のソースには適用されない。
// そのため、先に Embed API の transformRequest を走らせて、その後、更に変形する
Expand Down

0 comments on commit 68307e2

Please sign in to comment.