-
-
Notifications
You must be signed in to change notification settings - Fork 301
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Blank maps when using local mbtiles with local style on iOS #1366
Comments
Stupid iOS question, but can the iOS simulator read from the local file system? |
Afaik no |
it can, it does read and print the contents of the files. Checked already |
@prawel Yes you are right, since the style is definitely loaded from the local filesystem. I am not sure if the style syntax of the source is correct. See this comment: Definitely needs to be better documented. |
unfortunately, this is not the case, it didn't change much. |
Here is my attempt that appears to work. Very hackey and would love any suggestions to improve. struct MapView: UIViewRepresentable {
func makeUIView(context: Context) -> MGLMapView {
let mapView = MGLMapView(frame: .zero)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
mapView.delegate = context.coordinator
guard let localMbtiles = Bundle.main.url(forResource: "APT_BASE", withExtension: "mbtiles") else {
fatalError("Failed to find the style file.")
}
guard let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") else {
fatalError("Failed to find the style file.")
}
// Load the style.json template from your bundle
if let path = Bundle.main.path(forResource: "style", ofType: "json") {
do {
var styleJSON = try String(contentsOfFile: path, encoding: .utf8)
// let localMbString = localMb.absoluteString
styleJSON = styleJSON.replacingOccurrences(of: "{{LOCAL_FILE_NAME}}", with: localMbtiles.path)
let temporaryDirectory = FileManager.default.temporaryDirectory
let temporaryFileURL = temporaryDirectory.appendingPathComponent("temp_style.json")
try styleJSON.write(to: temporaryFileURL, atomically: true, encoding: .utf8)
// Set the temporary file's URL as the mapView.styleURL
mapView.styleURL = temporaryFileURL
} catch {
print("Error loading style.json template: \(error)")
}
}
... Style.json section:
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
I'm playing with MapLibre native library for ios and I get non-working behaviour. When I try using local mbtiles on iOS simulator, I get blank maps. Compass is visible, scale is visible, but the actual map contents are not.
The tiles I'm using were downloaded from https://data.maptiler.com/downloads/tileset/osm/europe/poland/, but it doesn't matter which one I try.
MapView.swift:
osmbright.json:
In debug panel in Xcode there is one message only: "will start rendering" which comes from this function:
I have not entered any key, because I'm using local files only.
Files are accessible from ios simulator, I've checked that.
Platform information
The text was updated successfully, but these errors were encountered: