You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Absolute file URL is treated as mapbox: style URL #3505
MGLMapView is seeing an absolute file URL and treating it as a mapbox: URL. The workaround is to use a relative URL. Relative URLs are calculated relative to the main bundle:
@1ec5 Don't you think it would be useful to also expose the setStyleJSON api ? Users could need to load dynamically constructed json strings (versus files).
Hm, it shouldn’t be necessary to use the asset: protocol – that’s an implementation detail. A relative URL like myfilename.json is expected to work. Reopening because we should get absolute file URLs to work too. It’s just a matter of calculating the common base between an absolute file path and the path to the main bundle.
Don't you think it would be useful to also expose the setStyleJSON api ?
This API was exposed way back when, until we removed it in #1184 to reduce MGLMapView’s complexity. Moreover, passing a JSON file as a string was unwieldy for manipulating more than the most simple of styles, since you had to serialize back and forth (see cutting-room-floor/mapbox-gl-cocoa#31). There are plans to introduce a proper, object-oriented style API (#837), which would address this and other use cases.
Activity
[-]Custom raster tiles[/-][+]Custom raster tiles don`t work with local styles[/+]ManuelRiegler commentedon Jan 11, 2016
When I upload my JSON file to a webserver it works:
NSString *urlstr = @"http://www.someurl.com/alpstein_raster.json";styleURL = [NSURL URLWithString:urlstr];1ec5 commentedon Jan 11, 2016
MGLMapView is seeing an absolute file URL and treating it as a mapbox: URL. The workaround is to use a relative URL. Relative URLs are calculated relative to the main bundle:
RomainQuidet commentedon Jan 11, 2016
confirmed, it's working on local file with [NSURL URLWithString:@"asset://myfilename.json"]
RomainQuidet commentedon Jan 11, 2016
@1ec5 Don't you think it would be useful to also expose the setStyleJSON api ? Users could need to load dynamically constructed json strings (versus files).
ManuelRiegler commentedon Jan 11, 2016
tx guys -> [NSURL URLWithString:@"asset://alpstein_raster.json"]; works
1ec5 commentedon Jan 11, 2016
Hm, it shouldn’t be necessary to use the asset: protocol – that’s an implementation detail. A relative URL like
myfilename.jsonis expected to work. Reopening because we should get absolute file URLs to work too. It’s just a matter of calculating the common base between an absolute file path and the path to the main bundle.This API was exposed way back when, until we removed it in #1184 to reduce MGLMapView’s complexity. Moreover, passing a JSON file as a string was unwieldy for manipulating more than the most simple of styles, since you had to serialize back and forth (see cutting-room-floor/mapbox-gl-cocoa#31). There are plans to introduce a proper, object-oriented style API (#837), which would address this and other use cases.
[-]Custom raster tiles don`t work with local styles[/-][+]Absolute file URL is treated as mapbox: style URL[/+]