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

Maptiler styles: "Error parsing style: source must have tiles" #24

Open
mikedbjones opened this issue Feb 10, 2025 · 2 comments
Open

Maptiler styles: "Error parsing style: source must have tiles" #24

mikedbjones opened this issue Feb 10, 2025 · 2 comments

Comments

@mikedbjones
Copy link

from pymgl import Map
from urllib.request import urlopen
import json

MAPTILER_KEY = ...

url = f"https://api.maptiler.com/maps/streets-v2/style.json?key={MAPTILER_KEY}"

with urlopen(url) as r:
    style = r.read()

map = Map(style.decode("UTF-8"))

img_bytes = map.renderPNG()

print('style keys...')
style_dict = json.loads(style)
for k in style_dict:
    print(k)

This code prints the following error (but does not raise an exception): "Error parsing style: source must have tiles". The map renders fine. The keys in the style are:

version
id
name
sources
layers
metadata
glyphs
sprite
bearing
pitch
center
zoom

tiles is not present, so I'm assuming the error comes from here. Since it does not affect map rendering, could it be inhibited?

@brendan-ward
Copy link
Owner

You are correct in the source of the error. Best place to take that up would be in maplibre-native.

During development, I found that some legitimate style errors - that would break rendering - were being logged in the same way as warnings, and the way they are wired into maplibre-native prevented actually catching those as exceptions and raising as an error on our end.

To help spot those, I added our own log recording here: log_observer. This monitors the log emitted by maplibre-native and tries to echo out useful things that would help with debugging. I didn't try to return these as Python warnings, so unfortunately, no easy way to prevent them from being logged out on your end.

I recall that there were some complexities on the maplibre-native side with raising exceptions during style parsing and rendering (had to do with the threading model, if I recall correctly), but I don't have time at the moment to track down the specific issue where that was mentioned over there. Check out their issues tracker; you'll likely find a mention of this issue over there.

@mikedbjones
Copy link
Author

Thanks for the response, I'll check it out at maplibre. Great tool, thank you.

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

No branches or pull requests

2 participants