detect map hash being passed more reliably to auto-set bounds [#246] (#251)

* add README for installing /app [#244]
This commit is contained in:
Brandon Liu
2023-09-11 11:05:50 +08:00
committed by GitHub
parent 009cd20ff4
commit 70146469e9
4 changed files with 19 additions and 9 deletions

View File

@@ -319,7 +319,7 @@ const vectorStyle = async (file: PMTiles): Promise<any> => {
};
};
function MaplibreMap(props: { file: PMTiles }) {
function MaplibreMap(props: { file: PMTiles; mapHashPassed: boolean }) {
let mapContainerRef = useRef<HTMLDivElement>(null);
let [hamburgerOpen, setHamburgerOpen] = useState<boolean>(true);
let [showAttributes, setShowAttributes] = useState<boolean>(false);
@@ -437,11 +437,7 @@ function MaplibreMap(props: { file: PMTiles }) {
if (mapRef.current) {
let map = mapRef.current;
let header = await props.file.getHeader();
if (
map.getCenter().lng === INITIAL_LNG &&
map.getCenter().lat == INITIAL_LAT &&
map.getZoom() === INITIAL_ZOOM
) {
if (!props.mapHashPassed) {
// the map hash was not passed, so auto-detect the initial viewport based on metadata
map.fitBounds(
[