GithubHelp home page GithubHelp logo

Comments (5)

boundsj avatar boundsj commented on June 18, 2024

Hi @wsnook fwiw; using singletons like NSNotificationCenter can make things a little harder to test compared to the much cleaner delegation pattern (or even a block callback). If there is a clear need to notify many disparate listeners about the failure of an MBXMapView init call then notification center or a well documented KVO scheme may be a good option... But, this seems more like something the delegate of the MBXMapView should be responsible for if the app developer wants to broadcast error conditions in notification center.

In mapbox/DEPRECATED-mapbox-ios-sdk#397 I provided a solution for a somewhat similar tile loading dilemma where the init method ends up making a synchronous networking call. The refactor I started there could be extended to also offer an error case delegate callback. A similar API in mbxmapkit would be awesome. Glad you guys are working on this!

Just my two cents!

from mbxmapkit.

 avatar commented on June 18, 2024

@boundsj, Thanks for the perspective. I'll check that out.

from mbxmapkit.

 avatar commented on June 18, 2024

I'm working a branch over at #73 which addresses this issue like so:

#pragma mark - Constants for the MBXMapKit error domain

extern NSString *const MBXMapKitErrorDomain;
extern NSInteger const MBXMapKitErrorCodeHTTPStatus;
extern NSInteger const MBXMapKitErrorCodeDictionaryMissingKeys;

#pragma mark - Delegate callbacks for asynchronous loading of map metadata and markers

@protocol MBXRasterTileOverlayDelegate <NSObject>
- (void)tileOverlay:(MBXRasterTileOverlay *)overlay didLoadMetadata:(NSDictionary *)metadata withError:(NSError *)error;
- (void)tileOverlay:(MBXRasterTileOverlay *)overlay didLoadMarkers:(NSArray *)markers withError:(NSError *)error;
- (void)tileOverlayDidFinishLoadingMetadataAndMarkersForOverlay:(MBXRasterTileOverlay *)overlay;
@end

#pragma mark -

@interface MBXRasterTileOverlay : MKTileOverlay

#pragma mark - Map tile overlay layer initialization and configuration

- (id)initWithMapID:(NSString *)mapID;
- (id)initWithMapID:(NSString *)mapID metadata:(BOOL)metadata markers:(BOOL)markers;
- (id)initWithMapID:(NSString *)mapID metadata:(BOOL)metadata markers:(BOOL)markers imageQuality:(MBXRasterImageQuality)imageQuality;

@property (weak,nonatomic) id<MBXRasterTileOverlayDelegate> delegate;

from mbxmapkit.

 avatar commented on June 18, 2024

For the implementation in the issue79 branch and PR #81, HTTP requests that yield a status code != 200 will trigger an error message getting passed back through the delegate callbacks. That should take care of it. The callbacks look like:

@protocol MBXRasterTileOverlayDelegate <NSObject>
- (void)tileOverlay:(MBXRasterTileOverlay *)overlay didLoadMetadata:(NSDictionary *)metadata withError:(NSError *)error;
- (void)tileOverlay:(MBXRasterTileOverlay *)overlay didLoadMarkers:(NSArray *)markers withError:(NSError *)error;
...
@end

and

@protocol MBXOfflineMapDownloaderDelegate <NSObject>
...
- (void)offlineMapDownloader:(MBXOfflineMapDownloader *)offlineMapDownloader didEncounterRecoverableError:(NSError *)error;
- (void)offlineMapDownloader:(MBXOfflineMapDownloader *)offlineMapDownloader didCompleteOfflineMapDatabase:(MBXOfflineMapDatabase *)offlineMapDatabase withError:(NSError *)error;
@end

from mbxmapkit.

incanus avatar incanus commented on June 18, 2024

#81 merged.

from mbxmapkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.