Add missing sourceDidChange event (#3421)

This commit is contained in:
Adrian Cojocaru
2025-04-22 21:05:36 +03:00
committed by GitHub
parent dfa8077134
commit fb224c25dc
8 changed files with 38 additions and 3 deletions

2
.gitmodules vendored
View File

@@ -57,7 +57,7 @@
url = https://github.com/protomaps/PMTiles.git url = https://github.com/protomaps/PMTiles.git
[submodule "vendor/maplibre-native-base/extras/args"] [submodule "vendor/maplibre-native-base/extras/args"]
path = vendor/maplibre-native-base/extras/args path = vendor/maplibre-native-base/extras/args
url = https://github.com/Taywee/args url = https://github.com/Taywee/args.git
[submodule "vendor/maplibre-native-base/extras/expected-lite"] [submodule "vendor/maplibre-native-base/extras/expected-lite"]
path = vendor/maplibre-native-base/extras/expected-lite path = vendor/maplibre-native-base/extras/expected-lite
url = https://github.com/martinmoene/expected-lite.git url = https://github.com/martinmoene/expected-lite.git

View File

@@ -2264,6 +2264,11 @@ CLLocationCoordinate2D randomWorldCoordinate(void) {
// MARK: - MLNMapViewDelegate // MARK: - MLNMapViewDelegate
- (void)mapView:(MLNMapView *)mapView sourceDidChange:(MLNSource *)source
{
NSLog(@"A source was updated: %@", source.identifier);
}
- (void)mapView:(MLNMapView *)mapView - (void)mapView:(MLNMapView *)mapView
shaderWillCompile:(NSInteger)id shaderWillCompile:(NSInteger)id
backend:(NSInteger)backend backend:(NSInteger)backend

View File

@@ -6933,8 +6933,13 @@ static void *windowScreenContext = &windowScreenContext;
} }
- (void)sourceDidChange:(MLNSource *)source { - (void)sourceDidChange:(MLNSource *)source {
// no-op: we only show attribution after tapping the info button, so there's no if (!_mbglMap) {
// interactive update needed. return;
}
if ([self.delegate respondsToSelector:@selector(mapView:sourceDidChange:)]) {
[self.delegate mapView:self sourceDidChange:source];
}
} }
- (void)didFailToLoadImage:(NSString *)imageName { - (void)didFailToLoadImage:(NSString *)imageName {

View File

@@ -302,6 +302,14 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style; - (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style;
/**
Tells the delegate that the source changed.
@param mapView The map view that owns the source.
@param source The source that changed.
*/
- (void)mapView:(MLNMapView *)mapView sourceDidChange:(MLNSource *)source;
/** /**
Tells the delegate that the `mapView` is missing an image. The image should be added synchronously Tells the delegate that the `mapView` is missing an image. The image should be added synchronously
with ``MLNStyle/setImage:forName:`` to be rendered on the current zoom level. When loading icons with ``MLNStyle/setImage:forName:`` to be rendered on the current zoom level. When loading icons

View File

@@ -30,6 +30,8 @@ extension MLNMapViewDelegateIntegrationTests: MLNMapViewDelegate {
func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {} func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {}
func mapView(_: MLNMapView, sourceDidChange _: MLNSource) {}
func mapView(_: MLNMapView, didSelect _: MLNAnnotation) {} func mapView(_: MLNMapView, didSelect _: MLNAnnotation) {}
func mapView(_: MLNMapView, didDeselect _: MLNAnnotation) {} func mapView(_: MLNMapView, didDeselect _: MLNAnnotation) {}

View File

@@ -984,6 +984,11 @@ public:
if (!_mbglMap) { if (!_mbglMap) {
return; return;
} }
if ([self.delegate respondsToSelector:@selector(mapView:sourceDidChange:)]) {
[self.delegate mapView:self sourceDidChange:source];
}
// Attribution only applies to tiled sources // Attribution only applies to tiled sources
if ([source isKindOfClass:[MLNTileSource class]]) { if ([source isKindOfClass:[MLNTileSource class]]) {
[self installAttributionView]; [self installAttributionView];

View File

@@ -204,6 +204,14 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style; - (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style;
/**
Tells the delegate that the source changed.
@param mapView The map view that owns the source.
@param source The source that changed.
*/
- (void)mapView:(MLNMapView *)mapView sourceDidChange:(MLNSource *)source;
/** /**
Tells the delegate that the `mapView` is missing an image. The image should be added synchronously Tells the delegate that the `mapView` is missing an image. The image should be added synchronously
with ``MLNStyle/setImage:forName:`` to be rendered on the current zoom level. When loading icons with ``MLNStyle/setImage:forName:`` to be rendered on the current zoom level. When loading icons

View File

@@ -38,6 +38,8 @@ extension MLNMapViewDelegateIntegrationTests: MLNMapViewDelegate {
func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {} func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {}
func mapView(_: MLNMapView, sourceDidChange _: MLNSource) {}
func mapViewWillStartRenderingFrame(_: MLNMapView) {} func mapViewWillStartRenderingFrame(_: MLNMapView) {}
func mapViewWillStartRenderingMap(_: MLNMapView) {} func mapViewWillStartRenderingMap(_: MLNMapView) {}