Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

asset://style.json loading is broken #3050

Closed
friedbunny opened this issue Nov 17, 2015 · 5 comments · Fixed by #3087
Closed

asset://style.json loading is broken #3050

friedbunny opened this issue Nov 17, 2015 · 5 comments · Fixed by #3087
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS

Comments

@friedbunny
Copy link
Contributor

It appears to be impossible to load local assets — such as styles — using the asset://foo.json URL scheme. This is a result of path problems, which we used to be able to work around using ../../ to get back to the main app bundle.

We've started pushing online styles exclusively (mapbox://styles/user/hash), but it should still be possible to load styles locally.

Follows on from #1208, which was specific to sprite loading.

/cc @incanus @1ec5 @jfirebaugh @kkaefer

@incanus
Copy link
Contributor

incanus commented Nov 17, 2015

Not-best-practice-but-perhaps-interesting-stopgap I was working on elsewhere for another purpose:

https://github.com/incanus/StyleServer

Tap the map view to toggle the style background color black and white. Fairly crappy since we don't yet have a native live style API, but a proof of concept nonetheless.

@1ec5
Copy link
Contributor

1ec5 commented Nov 17, 2015

I’m guessing this is because mbgl::platform::assetRoot() doesn’t take advantage of -[NSBundle(MGLAdditions) mgl_resourceBundlePath], which incidentally should use a dummy class instead of MGLMapView as a canary.

@mitchellporter
Copy link

@friedbunny

We've started pushing online styles exclusively (mapbox://styles/user/hash)

I'm trying to use a custom Mapbox Studio Beta map style in Xcode and can't get it to work. Have tried setting StyleID in Interface Builder, even removed chunks at a time, but still doesn't load properly: XcodeIB

Have also tried loading in code:

 mapView = MGLMapView(frame: view.bounds,
            styleURL: NSURL(string: "mapbox://styles/companyname/randomIDstring"))

Always receive the following error in Xcode 7.1.1 on OSX 10.11.1 with Cocoapods Mapbox iOS SDK 2.1.2: [ERROR] {Map}[Setup]: loading style failed: HTTP status code 403

Appreciate the help.

@friedbunny
Copy link
Contributor Author

@mitchellporter I don't see any GL styles in your Mapbox account, so the 403 error represents the fact that the style you're trying to load doesn't exist or, if it does exist, your access token does not have access to it.

@mitchellporter
Copy link

@friedbunny Yep, you're correct. I was using the API key for an old account sorry about that.

@1ec5 1ec5 self-assigned this Nov 20, 2015
1ec5 added a commit that referenced this issue Nov 20, 2015
As of #2746, we no longer bundle any styles with the SDK, so the asset: URL scheme is unused. Instead, point asset: to the application root for developer convenience and consistency with the Android and default asset roots. Also fixed an issue that prevented relative URLs from being treated as asset: URLs.

Fixes #1208, fixes #3050.
@1ec5 1ec5 removed the in progress label Nov 20, 2015
1ec5 added a commit that referenced this issue Nov 20, 2015
As of #2746, we no longer bundle any styles with the SDK, so the asset: URL scheme is unused. Instead, point asset: to the application root for developer convenience and consistency with the Android and default asset roots. Also fixed an issue that prevented relative URLs from being treated as asset: URLs.

Fixes #1208, fixes #3050.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants