-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
NSURL
on iOS 17 fails to parse double protocols for PMTiles
#3151
Comments
There are currently two proposals to fixing this:
|
I was able to reproduce this. I'll make a PR with a suggested solution. |
@KiwiKilian We already have a good workaround available, since the TileJSON constructor already uses Please see below. Is this an acceptable solution for you? - (void)addFoursquarePOIsPMTilesLayer {
// NOTE: the line below works on iOS 18 and up
// However, on iOS 17 the second : is stripped from the URL
// that is why we are using the TileJSON constructor as a workaround for this problem below
// MLNVectorTileSource *foursquareSource = [[MLNVectorTileSource alloc] initWithIdentifier:@"foursquare-10M" configurationURL:pmtilesURL];
MLNVectorTileSource *foursquareSource =
[[MLNVectorTileSource alloc] initWithIdentifier:@"foursquare-10M"
tileURLTemplates:@[@"pmtiles://https://oliverwipfli.ch/data/foursquare-os-places-10M-2024-11-20.pmtiles"]
options:nil];
// Add the source to the map style
[self.mapView.style addSource:foursquareSource];
// Initialize the circle style layer
MLNCircleStyleLayer *circleLayer = [[MLNCircleStyleLayer alloc] initWithIdentifier:@"foursquare-10M" source:foursquareSource];
circleLayer.sourceLayerIdentifier = @"place";
circleLayer.maximumZoomLevel = 11;
// Set the circle color
circleLayer.circleColor = [NSExpression expressionForConstantValue:[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0]];
// Set the circle opacity with interpolation
circleLayer.circleOpacity = [NSExpression expressionWithMLNJSONObject:@[
@"interpolate",
@[@"linear"],
@[@"zoom"],
@6, @0.5,
@11, @0.5,
@14, @1.0
]];
// Set the circle radius with interpolation
circleLayer.circleRadius = [NSExpression expressionWithMLNJSONObject:@[
@"interpolate",
@[@"linear"],
@[@"zoom"],
@6, @1,
@11, @3,
@16, @4,
@18, @8
]];
// Add the layer to the map style
[self.mapView.style addLayer:circleLayer];
} |
The workaround solves the problem, but it feels a bit hacky, as it's not an actual - (nullable MLNSource*)makeSource
{
if (self.url != nil) {
if([self.url hasPrefix:@"pmtiles://"]) {
return [[MLNVectorTileSource alloc] initWithIdentifier:self.id tileURLTemplates:@[self.url] options:nil];
} else {
return [[MLNVectorTileSource alloc] initWithIdentifier:self.id configurationURL:[NSURL URLWithString:self.url]];
}
}
return [[MLNVectorTileSource alloc] initWithIdentifier:self.id tileURLTemplates:self.tileUrlTemplates options:[self getOptions]];
} Of course we could also direct users to use the |
Why do you add this explicit check? Is there any downside from always using that approach? |
I would have guessed the two constructors are there for a reason? From the docs:
So don't they work partially different? The first one fetching a JSON and applying the options from there, while the other one just tries to load tiles from the URL and passing the options manually? Therefore I think its cleaner to properly use these constructors as intended? |
You're completely right. It just happens to work for PMTiles because the same URL can be used for both a TileJSON or a tile. I'll look into adding an NSString constructor then. |
MapLibre iOS Version
6.10.0
iOS Version
iOS 17.5
Device
Simulator
What happened?
Using PMTiles like
https://example.com/some.pmtiles
within aMLNVectorTileSource
on iOS 17 simulator fails (no crash) with the following error:Note the missing
:
in the parsed URL.Steps to reproduce
To break down the problem, it's enough to parse the URL. I've also included the proposal from @bdon for a more appropriate scheme (
pmtiles+https://
):We also used a basic PMTiles example within MapLibre React Native. It basically it creates an
MLNVectorTileSource
pmtiles://https://example.com/some.pmtiles
pmtiles+https://example.com/some.pmtiles
pmtiles://https://example.com/some.pmtiles
pmtiles+https://example.com/some.pmtiles
:
):pmtiles://https//example.com/some.pmtiles
❌ missing:
pmtiles+https://example.com/some.pmtiles
pmtiles://https://example.com/some.pmtiles
pmtiles+https://example.com/some.pmtiles
So it seems
NSURL
is only in iOS 17.x problematic, as I don't have any device running iOS 17 I can only reproduce using the simulator.The problem does not occur when using a
pmtiles://https://
scheme within a style JSON set asstyleURL
– through this use case the URLs aren't parsed asNSURL
. The problem only occurs when creating aMLNVectorTileSource
.The text was updated successfully, but these errors were encountered: