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

How to display map image as background using json file style - Android Mapbox SDK #3282

Closed
Mizuki123 opened this issue Dec 14, 2015 · 5 comments

Comments

@Mizuki123
Copy link

Hi everyone,

I'm working on a simple Android application that should display a simple map as background using Mapbox SDK.

For this, I edited a json file that defines the mapbox style of my Android MapView object according this documentation : https://www.mapbox.com/mapbox-gl-style-spec/. Then, I stored this stylesheet in my own http server (nodejs).

Althought my application can access my style file, unfortunately the sdk returns a Failed to parse error with 0: Invalid value.

Is anyone knows what's wrong in my stylesheet ? Are there specific attributes/values missing on my stylesheet ?

In attachment, I posted my json style, the android code source that initializes my MapView and the error log that the sdk returns.

The parsing error is quite strange, does it refer to parsing the url or parsing the json file or parsing the png ?

Thanks

capture d ecran 2015-12-14 a 17 00 20

capture d ecran 2015-12-14 a 17 00 38

capture d ecran 2015-12-14 a 17 01 39

@friedbunny
Copy link
Contributor

We don't yet have full support for the style spec — image sources are not currently implemented. This is covered by #1350.

{Map}[Style]: Failed to parse [image.png]: 0 - Invalid value.

This error should be much clearer, sorry about that.

@friedbunny
Copy link
Contributor

As a workaround, you might try background-pattern, which does support images.

@Mizuki123
Copy link
Author

Thanks you for your answer. I will try with this.

In addition, I wondering if I could have a background with raster type for the source json attribute

@friedbunny
Copy link
Contributor

The raster type expects XYZ tiled images, as provided by Mapbox or other tile services. Check out the custom raster style example and the two included style JSON files for how to implement this.

@Mizuki123
Copy link
Author

Ok thank you.

I finally used the raser type method fo display my map. However, I eventually want to center my map in a specific longitude and latitude (eg. latitude = -6.2488 and longitude = 53.3330 for Dublin).

I used the center attribute with this values to set the center in Dublin. But, when my map is displayed, the center is not Dublin but the default center in lat = 0 and lon = 0.

Is center attribute is the correct way to set the center of my map ?

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

No branches or pull requests

2 participants