diff options
author | Jordan Kiley <jmkiley@users.noreply.github.com> | 2019-04-03 12:37:56 -0700 |
---|---|---|
committer | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2019-04-03 12:37:56 -0700 |
commit | 1aa705c2f6124584b6dc562fd2cfc0c40dba8df8 (patch) | |
tree | be9e33b3346f91604b3bc5a04e6d6ae853ba13e0 /platform/ios/src | |
parent | f3c3dc49e231208e75db64b53c5e92bb9647a661 (diff) | |
download | qtlocation-mapboxgl-1aa705c2f6124584b6dc562fd2cfc0c40dba8df8.tar.gz |
[ios] Add iOS bindings and example for missing icons event. (#14302)
Added a new mapView delegate method that allows reload a style icon in case it couldn't load it from the style.
Added an iosapp test example.
Diffstat (limited to 'platform/ios/src')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 14 | ||||
-rw-r--r-- | platform/ios/src/MGLMapViewDelegate.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 813762c499..715929818f 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -6827,6 +6827,20 @@ public: void onDidFinishLoadingStyle() override { [nativeView didFinishLoadingStyle]; } + + void onStyleImageMissing(const std::string& imageIdentifier) override { + NSString *imageName = [NSString stringWithUTF8String:imageIdentifier.c_str()]; + + if ([nativeView.delegate respondsToSelector:@selector(mapView:didFailToLoadImage:)]) { + UIImage *imageToLoad = [nativeView.delegate mapView:nativeView didFailToLoadImage:imageName]; + + if (imageToLoad) { + auto image = [imageToLoad mgl_styleImageWithIdentifier:imageName]; + nativeView.mbglMap.getStyle().addImage(std::move(image)); + } + + } + } mbgl::gl::ProcAddress getExtensionFunctionPointer(const char* name) override { static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengles")); diff --git a/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/src/MGLMapViewDelegate.h index 7e098f340d..055d4c9517 100644 --- a/platform/ios/src/MGLMapViewDelegate.h +++ b/platform/ios/src/MGLMapViewDelegate.h @@ -275,6 +275,8 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style; +- (nullable UIImage *)mapView:(MGLMapView *)mapView didFailToLoadImage:(NSString *)imageName; + #pragma mark Tracking User Location /** |