Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pmtiles center coordinates wrong (was:not able to render pmtiles file in maplibreGL) #193

Closed
eliboni opened this issue Dec 26, 2023 · 7 comments · Fixed by onthegomap/planetiler#769

Comments

@eliboni
Copy link

eliboni commented Dec 26, 2023

I've generated pmtiles file for Malta via basemap and serving it via http-server.

I can display them fine within leaflet with protomapsL.leafletLayer - here the index.html snippet:

<div id="map"></div> 
<script>
	    const map = L.map('map')
            map.setView(new L.LatLng(35.8836,14.4468),14);
	    var layer = protomapsL.leafletLayer({url:'http://192.168.1.178:8080/malta.pmtiles'})
	    layer.addTo(map)
            layer.addInspector(map)
            // layer.removeInspector(map)
</script>

malta-leaflet-ok

I'm now trying to render it via maplibreGL but I just get an empty screen (no console errors), it is as if the layers are not loaded correctly: however when I drop the pmtiles file in https://maps.protomaps.com it displayes jiust fine and I got the JSON style - here is index.html:

        <script>
            let protocol = new pmtiles.Protocol();
            maplibregl.addProtocol("pmtiles",protocol.tile); 
	    let PMTILES_URL = "http://192.168.1.178:8080/malta.pmtiles";
            const p = new pmtiles.PMTiles(PMTILES_URL);
            protocol.add(p);
            p.getHeader().then(h => {
                const map = new maplibregl.Map({
                    container: 'map',
                    zoom: h.maxZoom-2,
                    center: [h.centerLon, h.centerLat],
                    style: 'http://192.168.1.178:8080/mystyle.json'
                });
                map.showTileBoundaries = true;
            });

        </script>

and mystyle.json is attached: mystyle.json
malta-mapboxGL-ko

Is anyone so kind to give me an hint on what I am doing wrong? Thanks in advance

@bdon
Copy link
Member

bdon commented Dec 27, 2023

we need your malta.pmtiles to reproduce, please upload that somewhere

@eliboni
Copy link
Author

eliboni commented Dec 27, 2023

@bdon
Copy link
Member

bdon commented Dec 27, 2023

Your PMTiles header has center lon, center lat: 14, 35: whole numbers instead of a precise point that is close to Malta. So your viewport is far off where it should be. Did you override the determination of the center somehow?

@eliboni
Copy link
Author

eliboni commented Dec 27, 2023

nope, I've just run this command:

java -jar target/*-with-deps.jar --download --force --area=malta

@eliboni
Copy link
Author

eliboni commented Dec 27, 2023

btw - you're perfectly right: just modified my code with the proper lat/lon (center: [14.4468, 35.8836]) and I see it properly:

<div id="map"></div> 
        <script>
            let protocol = new pmtiles.Protocol();
            maplibregl.addProtocol("pmtiles",protocol.tile); 
	    let PMTILES_URL = "http://192.168.1.178:8080/malta.pmtiles";
            const p = new pmtiles.PMTiles(PMTILES_URL);
            protocol.add(p);
            p.getHeader().then(h => {
                const map = new maplibregl.Map({
                    container: 'map',
                    zoom: h.maxZoom-2,
                    center: [14.4468, 35.8836],
                    style: 'http://192.168.1.178:8080/mystyle.json'
                });
                map.showTileBoundaries = true;
            });
        </script>

let me know if you want me to do some tests on why the default center does not contain precise point , I've used basemaps master from yesterday.

@bdon
Copy link
Member

bdon commented Dec 28, 2023

Thanks for reporting, will be fixed by onthegomap/planetiler#769 upstream

@bdon bdon changed the title not able to render pmtiles file in maplibreGL pmtiles center coordinates wrong (was:not able to render pmtiles file in maplibreGL) Dec 28, 2023
@bdon
Copy link
Member

bdon commented Dec 28, 2023

Updating your planetiler dependency via mvn -U clean package should fix it. Please re-open if you're encountering the same issue, thanks!

@bdon bdon closed this as completed Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants