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

Allow Mapbox to load local json map style definition #261

Merged
merged 5 commits into from
Sep 25, 2018

Conversation

lbaey
Copy link

@lbaey lbaey commented Sep 24, 2018

Hi
I needed to load a different than "native mapbox style" in my map.
I added the ability to load a json map style file definition with a new special url pointing at the "assets" nativescript directory.
The Url is assets:// and points to the /app/assets/ directory of your project.
Usage example :

onMapReady(args) {
                console.log("Switching Style");
                args.map.setMapStyle("assets://RM-raster-style.json");
}

Tell me what you think and if you think this is a good approach.
Cheers

@EddyVerbruggen
Copy link
Collaborator

Hi! I think that's a great approach, but perhaps it's worthwhile to explore the possibility of using ~/yourfile.json instead because that's the standard NativeScript approach to reference files in the /app folder (~ being and alias for app). Do you think that would be possible? That way users aren't forced to create an assets folder to store the file in.

Can you perhaps also add a sample json file to the demo in the repo? I'd love to play with it!

@lbaey
Copy link
Author

lbaey commented Sep 25, 2018

OK, I was not sure on how to refer to local path, but the nativescript "~" seems ideal.
I've switched to this URL scheme tracking to let mapbox load the json file.
I've also added some doc and (untested and commented) example so you can play ;)

@EddyVerbruggen
Copy link
Collaborator

Awesome! I'll be testing this soon.

@EddyVerbruggen EddyVerbruggen added this to the 4.3.0 milestone Sep 25, 2018
@EddyVerbruggen EddyVerbruggen merged commit 500ff13 into Yermo:master Sep 25, 2018
@lbaey lbaey deleted the json-style branch September 25, 2018 14:42
@EddyVerbruggen
Copy link
Collaborator

Works like a charm! I only tested with ~/ though. THANKS!

@ansarikhurshid786
Copy link

I want load local json. can you give me an example which work in android and ios.
Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants