Comments (5)
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.
@boundsj, Thanks for the perspective. I'll check that out.
from mbxmapkit.
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.
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.
#81 merged.
from mbxmapkit.
Related Issues (20)
- MKOverlayRenderer setNeedsDisplayInMapRect:zoomScale: HOT 6
- [VKTileKeyMap enumerateKeysAndObjectsUsingBlock:] HOT 16
- how to grant app to use my api access token? HOT 1
- React Native Module HOT 1
- BSD license HOT 4
- warning in new Xcode on canReplaceMapContent
- mbx_zoomLevel might return the wrong zoom level
- MBXMapKitErrorCodeOfflineMapSqlite to delegate
- MBXMapKit Example App high CPU usage HOT 7
- Crashes in [VKRasterOverlayTileSource invalidateRect:level:] and [VKTileKeyMap enumerateKeysAndObjectsUsingBlock:] HOT 2
- MBXOfflineMapDownloader suspend/resume sequence and activeDataSessionTasks count HOT 3
- Redundant tile loads in MBXRasterTileRenderer canDrawMapRect: when using 512px tiles HOT 6
- Swift: MGLMultiPoint should use Int for pointCount HOT 3
- Remove `example.mapids` and make sure offline works
- deprecate repo in favor of GL HOT 8
- random crashes coming from MBXMapKit/VectorKit HOT 1
- Is 0.8.0 / v4 API backwards compatible? HOT 1
- MapID problem? HOT 1
- Remove mb-pages branch HOT 1
- IOS SDK Cluster effect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mbxmapkit.