@@ -889,18 +889,17 @@ - (void)mapViewDidFinishLoadingMap {
889
889
}
890
890
}
891
891
892
- - (void)mapViewDidFailLoadingMap {
892
+ - (void )mapViewDidFailLoadingMapWithError:( NSError *)error {
893
893
if (!_mbglMap) {
894
894
return ;
895
895
}
896
896
897
897
if ([self .delegate respondsToSelector: @selector (mapViewDidFailLoadingMap:withError: )]) {
898
- NSError *error = [NSError errorWithDomain:MGLErrorDomain code:0 userInfo:nil];
899
898
[self .delegate mapViewDidFailLoadingMap: self withError: error];
900
899
}
901
900
}
902
901
903
- - (void)MapViewWillStartRenderingFrame {
902
+ - (void )mapViewWillStartRenderingFrame {
904
903
if (!_mbglMap) {
905
904
return ;
906
905
}
@@ -2794,12 +2793,29 @@ void onDidFinishLoadingMap() override {
2794
2793
[nativeView mapViewDidFinishLoadingMap ];
2795
2794
}
2796
2795
2797
- void onDidFailLoadingMap() override {
2798
- [nativeView mapViewDidFailLoadingMap];
2796
+ void onDidFailLoadingMap (mbgl::MapObserver::ErrorType type, const std::string& message) override {
2797
+ NSError *error;
2798
+ NSString *errorDescription = @(message.c_str ());
2799
+ MGLErrorCode errorCode;
2800
+ switch (type) {
2801
+ case mbgl::MapObserver::ErrorType::ParseStyle:
2802
+ errorCode = MGLErrorCodeParseStyleFailed;
2803
+ break ;
2804
+ case mbgl::MapObserver::ErrorType::NotFound:
2805
+ errorCode = MGLErrorCodeNotFound;
2806
+ break ;
2807
+ case mbgl::MapObserver::ErrorType::LoadingStyle:
2808
+ errorCode = MGLErrorCodeLoadStyleFailed;
2809
+ break ;
2810
+ }
2811
+ error = [NSError errorWithDomain: MGLErrorDomain code: errorCode userInfo: errorDescription ? @{
2812
+ NSLocalizedDescriptionKey : errorDescription,
2813
+ } : nil ];
2814
+ [nativeView mapViewDidFailLoadingMapWithError: error];
2799
2815
}
2800
2816
2801
2817
void onWillStartRenderingFrame () override {
2802
- [nativeView MapViewWillStartRenderingFrame ];
2818
+ [nativeView mapViewWillStartRenderingFrame ];
2803
2819
}
2804
2820
2805
2821
void onDidFinishRenderingFrame (mbgl::MapObserver::RenderMode mode) override {
0 commit comments