flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 503 forks source link

Setting style as a json object directly for web #1279

Closed srmncnk closed 1 year ago

srmncnk commented 1 year ago

This PR enabled users to set style as a json object directly in flutter for Web.

This is already supported by the underlying mapbox_gl_dart package, the usage of it in this package is corrected.

srmncnk commented 1 year ago

@felix-ht Yes, it works.

aardrop commented 11 months ago

@srmncnk Does this work for you, and if so how are you formatting the json? We use a stored file for our json styles but can't seem to get web to read them either as a direct string or file URL (which I note doesn't look to be set up)

srmncnk commented 11 months ago

@aardrop Sorry for the late reply. Since interfaces are fixed, you always have to pass a string. String can be either a url to a style or a formatted json of a style (as a string). I'm pretty sure local file URL in the style won't work though.

aardrop commented 10 months ago

Thanks @srmncnk, I got that far, but I currently can't get any string json or string URL to work for Mapbox other than the basic on in the example.

For example, this public URL (I will delete it shortly after you have a second to look at it) "mapbox://styles/outway-admin/clox96ha6008n01pqdvps37ew"and the related JSON as a string both don't work. The string URL gets ignored completely, and the json breaks the map, so nothing loads. Do you have an example of how you formatted the json?

IDK if there is anything special to consider, I can test our json all the way to your code in the repo, but once it leaves there, I don't get any errors and can't find where it's breaking.

srmncnk commented 10 months ago

I suggest you use Maputnik to test the style. Anything that renders there will render here as well.

aardrop commented 10 months ago

That's a helpful resource and helped me solve something else, but I'm getting the following error with a string JSON object still. Is there any special formatting I need to do besides just putting the json in a string?

Screenshot 2023-11-13 at 3 10 54 PM
aardrop commented 10 months ago

Through a vary annoying process, I finally found a problem. In the exported JSON from mapbox there was some unregistered character in the airport-label layer that was breaking the whole thing.