-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Absolute file URL is treated as mapbox: style URL #3505
Comments
When I upload my JSON file to a webserver it works: |
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: [NSURL URLWithString:@"alpstein_raster"] |
confirmed, it's working on local file with [NSURL URLWithString:@"asset://myfilename.json"] |
@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). |
tx guys -> [NSURL URLWithString:@"asset://alpstein_raster.json"]; works |
Hm, it shouldn’t be necessary to use the asset: protocol – that’s an implementation detail. A relative URL like
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. |
Hi guys,
I try to use custom raster tiles in my project but I always get the following error:
"loading style failed: HTTP status code 401"
My MGLMapView is embed in an .xib file with just the default settings and I set the styleURL within the code (using local styles):
NSString *path = [[NSBundle mainBundle] pathForResource:@"alpstein_raster" ofType:@"json"]; styleURL = [NSURL URLWithString:path]; self.mapView.styleURL = styleURL;
My alpstein_raster json looks like:
I don´t set an AccessTokes since I don´t use MapBox Tilessources.
Any idea what I am doing wrong?
Tx for help,
Askin
The text was updated successfully, but these errors were encountered: