-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support instantiating VectorSource and TileSource with a TileSet programmatically #241
Comments
Which platform, and what's the exception in the crash log (if any?) |
Ah, I see, it's because on Android I parse it to a java.net.URI to check the scheme and modify it (in case it's a compose resource) Will fix |
Fix is going out in v0.6.0, lmk how it goes |
@sargunv thank you! |
So it doesn't crash, but I still don't think it's using the url correctly. It just says |
I believe it's still unnecessarily encoding it. I see another log |
Could you share a code sample of using it with the Kotlin SDK? |
And in this library I am doing
|
Ah I see, that particular VectorSource constructor isn't implemented in this library yet. You can see how we initialize VectorSource here: Lines 6 to 8 in fad1b99
MapLibre expects that URL to point to TileJSON: https://maplibre.org/maplibre-native/android/api/-map-libre%20-native%20-android/org.maplibre.android.style.sources/-vector-source/index.html
So you should be able to make this work by creating a TileJSON resource under |
Or, here's an example of how to do it now: val crags = rememberVectorSource(
id = "openbeta-crags",
uri = Res.getUri("files/data/openbeta-crags.json")
)
SymbolLayer(
id = "crag-name-label",
source = crags,
sourceLayer = "crags",
iconAnchor = const(SymbolAnchor.Center),
textField = feature.get("name").convertToString(),
textFont = const(listOf("Noto Sans Regular"))
) {
"tiles": [
"https://maptiles.openbeta.io/crags/{z}/{x}/{y}.pbf"
],
"promoteId": "id",
"maxzoom": 11,
"attribution": "© OpenBeta contributors"
} |
Amazing! Thank you. I actually like this way of configuring better, but the documentation is a bit sparse so I didn't know you had to put it in a json file. |
Feel free to PR improvements to the docs; the relevant file for this one is here: https://github.com/sargunv/maplibre-compose/blob/main/docs/docs/layers.md |
I am unable to get a vector source with a .pbf format working. For example if I use the url
https://maptiles.openbeta.io/crags/{z}/{x}/{y}.pbf
as the uri, it crashes because it can't parse the{
character. If I utf 8 encode it, it won't crash, but it cannot find the resource because it doesn't decode it before attempting to request the tiles. How am I supposed to pass in this url? I am usingrememberVectorSource("id", "https://maptiles.openbeta.io/crags/{z}/{x}/{y}.pbf")
The text was updated successfully, but these errors were encountered: