Skip to content

Commit d5ac30e

Browse files
authored
Merge branch 'main' into dynamic-texture-atlas
2 parents 1c32a30 + ce4dcb7 commit d5ac30e

26 files changed

+1022
-6
lines changed

.github/workflows/gh-pages-android-api.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: ./gradlew dokkaGenerate
2727

2828
- name: Deploy 🚀
29-
uses: JamesIves/github-pages-deploy-action@v4.7.2
29+
uses: JamesIves/github-pages-deploy-action@v4.7.3
3030
with:
3131
branch: gh-pages
3232
folder: platform/android/MapLibreAndroid/build/dokka/html

.github/workflows/gh-pages-android-examples.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: make mkdocs-build
2424

2525
- name: Deploy 🚀
26-
uses: JamesIves/github-pages-deploy-action@v4.7.2
26+
uses: JamesIves/github-pages-deploy-action@v4.7.3
2727
with:
2828
branch: gh-pages
2929
folder: platform/android/site

.github/workflows/gh-pages-cpp-api.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: doxygen
2121

2222
- name: Deploy 🚀
23-
uses: JamesIves/github-pages-deploy-action@v4.7.2
23+
uses: JamesIves/github-pages-deploy-action@v4.7.3
2424
with:
2525
branch: gh-pages
2626
folder: docs/doxygen/html

.github/workflows/gh-pages-docc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
rm docs.zip
6868
6969
- name: Deploy DocC documentation (main) 🚀
70-
uses: JamesIves/github-pages-deploy-action@v4.7.2
70+
uses: JamesIves/github-pages-deploy-action@v4.7.3
7171
with:
7272
branch: gh-pages
7373
folder: build/docs

.github/workflows/gh-pages-mdbook.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
name: book
4444
path: artifacts/book
4545
- name: Deploy
46-
uses: JamesIves/github-pages-deploy-action@v4.7.2
46+
uses: JamesIves/github-pages-deploy-action@v4.7.3
4747
with:
4848
branch: gh-pages
4949
folder: artifacts/book

.github/workflows/qt-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ jobs:
182182
arch: ${{ matrix.compiler_type }}
183183

184184
- name: Setup ninja
185-
uses: seanmiddleditch/gha-setup-ninja@v5
185+
uses: seanmiddleditch/gha-setup-ninja@v6
186186

187187
- name: Download Qt
188188
uses: jurplel/install-qt-action@v4

platform/darwin/bazel/files.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ MLN_DARWIN_OBJC_HEADERS = [
9393
"src/MLNStyle.h",
9494
"src/MLNStyleLayer.h",
9595
"src/MLNStyleValue.h",
96+
"src/MLNTileOperation.h",
9697
"src/MLNTilePyramidOfflineRegion.h",
9798
"src/MLNTileServerOptions.h",
9899
"src/MLNTileSource.h",
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#import <Foundation/Foundation.h>
2+
3+
typedef NS_ENUM(NSInteger, MLNTileOperation) {
4+
MLNTileOperationRequestedFromCache, ///< A read request from the cache
5+
MLNTileOperationRequestedFromNetwork, ///< A read request from the online source
6+
MLNTileOperationLoadFromNetwork, ///< Tile data from the network has been retrieved
7+
MLNTileOperationLoadFromCache, ///< Tile data from the cache has been retrieved
8+
MLNTileOperationStartParse, ///< Background processing of tile data has been initiated
9+
MLNTileOperationEndParse, ///< Background processing of tile data has been completed
10+
MLNTileOperationError, ///< An error occurred while loading the tile
11+
MLNTileOperationCancelled, ///< Loading of a tile was cancelled
12+
MLNTileOperationNullOp, ///< No operation has taken place
13+
};

platform/ios/MapLibre.docc/MapLibre.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Powerful, free and open-source mapping toolkit with full control over data sourc
5151

5252
### Advanced
5353

54+
- <doc:ObserverExample>
5455
- <doc:CustomStyleLayerExample>
5556

5657
### Other Articles
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Observe Low-Level Events
2+
3+
Learn about the ``MLNMapViewDelegate`` methods for observing map events.
4+
5+
> Warning: These methods are not thread-safe.
6+
7+
You can observe certain low-level events as they happen. Use these methods to collect metrics or investigate issues during map rendering. This feature is intended primarily for power users. We are always interested in improving observability, so if you have a special use case, feel free to [open an issue or pull request](https://github.com/maplibre/maplibre-native) to extend the types of observability methods.
8+
9+
## Shader Events
10+
11+
Observe shader compilation with ``MLNMapViewDelegate/mapView:shaderWillCompile:backend:defines:`` and ``MLNMapViewDelegate/mapView:shaderDidCompile:backend:defines:``.
12+
13+
<!-- include-example(ObserverExampleShaders) -->
14+
15+
```swift
16+
func mapView(_: MLNMapView, shaderWillCompile id: Int, backend: Int, defines: String) {
17+
print("A new shader is being compiled - shaderID:\(id), backend type:\(backend), program configuration:\(defines)")
18+
}
19+
20+
func mapView(_: MLNMapView, shaderDidCompile id: Int, backend: Int, defines: String) {
21+
print("A shader has been compiled - shaderID:\(id), backend type:\(backend), program configuration:\(defines)")
22+
}
23+
```
24+
25+
See also: ``MLNMapViewDelegate/mapView:shaderDidFailCompile:backend:defines:``.
26+
27+
## Glyph Loading
28+
29+
Observe glyph loading events with ``MLNMapViewDelegate/mapView:glyphsWillLoad:range:`` and ``MLNMapViewDelegate/mapView:glyphsDidLoad:range:``.
30+
31+
<!-- include-example(ObserverExampleGlyphs) -->
32+
33+
```swift
34+
func mapView(_: MLNMapView, glyphsWillLoad fontStack: [String], range: NSRange) {
35+
print("Glyphs are being requested for the font stack \(fontStack), ranging from \(range.location) to \(range.location + range.length)")
36+
}
37+
38+
func mapView(_: MLNMapView, glyphsDidLoad fontStack: [String], range: NSRange) {
39+
print("Glyphs have been loaded for the font stack \(fontStack), ranging from \(range.location) to \(range.location + range.length)")
40+
}
41+
```
42+
43+
See also: ``MLNMapViewDelegate/mapView:glyphsDidError:range:``.
44+
45+
## Tile Events
46+
47+
Monitor tile-related actions using the delegate method ``MLNMapViewDelegate/mapView:tileDidTriggerAction:x:y:z:wrap:overscaledZ:sourceID:`` with the ``MLNTileOperation`` type.
48+
49+
<!-- include-example(ObserverExampleTiles) -->
50+
51+
```swift
52+
func mapView(_: MLNMapView, tileDidTriggerAction operation: MLNTileOperation,
53+
x: Int,
54+
y: Int,
55+
z: Int,
56+
wrap: Int,
57+
overscaledZ: Int,
58+
sourceID: String)
59+
{
60+
let tileStr = String(format: "(x: %ld, y: %ld, z: %ld, wrap: %ld, overscaledZ: %ld, sourceID: %@)",
61+
x, y, z, wrap, overscaledZ, sourceID)
62+
63+
switch operation {
64+
case MLNTileOperation.requestedFromCache:
65+
print("Requesting tile \(tileStr) from cache")
66+
67+
case MLNTileOperation.requestedFromNetwork:
68+
print("Requesting tile \(tileStr) from network")
69+
70+
case MLNTileOperation.loadFromCache:
71+
print("Loading tile \(tileStr), requested from the cache")
72+
73+
case MLNTileOperation.loadFromNetwork:
74+
print("Loading tile \(tileStr), requested from the network")
75+
76+
case MLNTileOperation.startParse:
77+
print("Parsing tile \(tileStr)")
78+
79+
case MLNTileOperation.endParse:
80+
print("Completed parsing tile \(tileStr)")
81+
82+
case MLNTileOperation.error:
83+
print("An error occured during proccessing for tile \(tileStr)")
84+
85+
case MLNTileOperation.cancelled:
86+
print("Pending work on tile \(tileStr)")
87+
88+
case MLNTileOperation.nullOp:
89+
print("An unknown tile operation was emitted for tile \(tileStr)")
90+
91+
@unknown default:
92+
assertionFailure()
93+
}
94+
}
95+
```
96+
97+
## Sprite Loading
98+
99+
Observe sprite loading events with ``MLNMapViewDelegate/mapView:spriteWillLoad:url:`` and ``MLNMapViewDelegate/mapView:spriteDidLoad:url:``.
100+
101+
<!-- include-example(ObserverExampleSprites) -->
102+
103+
```swift
104+
func mapView(_: MLNMapView, spriteWillLoad id: String, url: String) {
105+
print("The sprite \(id) has been requested from \(url)")
106+
}
107+
108+
func mapView(_: MLNMapView, spriteDidLoad id: String, url: String) {
109+
print("The sprite \(id) has been loaded from \(url)")
110+
}
111+
```
112+
113+
See also: ``MLNMapViewDelegate/mapView:spriteDidError:url:``.

platform/ios/app-swift/Sources/MapLibreNavigationView.swift

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ struct MapLibreNavigationView: View {
3434
NavigationLink("AddMarkerExample") {
3535
AddMarkerSymbolExampleUIViewControllerRepresentable()
3636
}
37+
NavigationLink("ObserverExample") {
38+
ObserverExampleViewExampleUIViewControllerRepresentable()
39+
}
3740
Group {
3841
NavigationLink("AnimatedLineExample") {
3942
AnimatedLineExampleUIViewControllerRepresentable()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import MapLibre
2+
import SwiftUI
3+
import UIKit
4+
5+
class ObserverExampleView: UIViewController, MLNMapViewDelegate {
6+
var mapView: MLNMapView!
7+
8+
override func viewDidLoad() {
9+
super.viewDidLoad()
10+
11+
mapView = MLNMapView(frame: view.bounds, styleURL: AMERICANA_STYLE)
12+
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
13+
14+
mapView.setCenter(
15+
CLLocationCoordinate2D(latitude: 45.5076, longitude: -122.6736),
16+
zoomLevel: 11,
17+
animated: false
18+
)
19+
view.addSubview(mapView)
20+
21+
mapView.delegate = self
22+
}
23+
24+
// #-example-code(ObserverExampleShaders)
25+
func mapView(_: MLNMapView, shaderWillCompile id: Int, backend: Int, defines: String) {
26+
print("A new shader is being compiled - shaderID:\(id), backend type:\(backend), program configuration:\(defines)")
27+
}
28+
29+
func mapView(_: MLNMapView, shaderDidCompile id: Int, backend: Int, defines: String) {
30+
print("A shader has been compiled - shaderID:\(id), backend type:\(backend), program configuration:\(defines)")
31+
}
32+
33+
// #-end-example-code
34+
35+
// #-example-code(ObserverExampleGlyphs)
36+
func mapView(_: MLNMapView, glyphsWillLoad fontStack: [String], range: NSRange) {
37+
print("Glyphs are being requested for the font stack \(fontStack), ranging from \(range.location) to \(range.location + range.length)")
38+
}
39+
40+
func mapView(_: MLNMapView, glyphsDidLoad fontStack: [String], range: NSRange) {
41+
print("Glyphs have been loaded for the font stack \(fontStack), ranging from \(range.location) to \(range.location + range.length)")
42+
}
43+
44+
// #-end-example-code
45+
46+
// #-example-code(ObserverExampleTiles)
47+
func mapView(_: MLNMapView, tileDidTriggerAction operation: MLNTileOperation,
48+
x: Int,
49+
y: Int,
50+
z: Int,
51+
wrap: Int,
52+
overscaledZ: Int,
53+
sourceID: String)
54+
{
55+
let tileStr = String(format: "(x: %ld, y: %ld, z: %ld, wrap: %ld, overscaledZ: %ld, sourceID: %@)",
56+
x, y, z, wrap, overscaledZ, sourceID)
57+
58+
switch operation {
59+
case MLNTileOperation.requestedFromCache:
60+
print("Requesting tile \(tileStr) from cache")
61+
62+
case MLNTileOperation.requestedFromNetwork:
63+
print("Requesting tile \(tileStr) from network")
64+
65+
case MLNTileOperation.loadFromCache:
66+
print("Loading tile \(tileStr), requested from the cache")
67+
68+
case MLNTileOperation.loadFromNetwork:
69+
print("Loading tile \(tileStr), requested from the network")
70+
71+
case MLNTileOperation.startParse:
72+
print("Parsing tile \(tileStr)")
73+
74+
case MLNTileOperation.endParse:
75+
print("Completed parsing tile \(tileStr)")
76+
77+
case MLNTileOperation.error:
78+
print("An error occured during proccessing for tile \(tileStr)")
79+
80+
case MLNTileOperation.cancelled:
81+
print("Pending work on tile \(tileStr)")
82+
83+
case MLNTileOperation.nullOp:
84+
print("An unknown tile operation was emitted for tile \(tileStr)")
85+
86+
@unknown default:
87+
assertionFailure()
88+
}
89+
}
90+
91+
// #-end-example-code
92+
93+
// #-example-code(ObserverExampleSprites)
94+
func mapView(_: MLNMapView, spriteWillLoad id: String, url: String) {
95+
print("The sprite \(id) has been requested from \(url)")
96+
}
97+
98+
func mapView(_: MLNMapView, spriteDidLoad id: String, url: String) {
99+
print("The sprite \(id) has been loaded from \(url)")
100+
}
101+
// #-end-example-code
102+
}
103+
104+
struct ObserverExampleViewExampleUIViewControllerRepresentable: UIViewControllerRepresentable {
105+
typealias UIViewControllerType = ObserverExampleView
106+
107+
func makeUIViewController(context _: Context) -> ObserverExampleView {
108+
ObserverExampleView()
109+
}
110+
111+
func updateUIViewController(_: ObserverExampleView, context _: Context) {}
112+
}

0 commit comments

Comments
 (0)