This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import "MGLFoundation.h" | ||
#import "MGLGeometry.h" | ||
#import "MGLTileSource.h" | ||
|
||
MGL_EXPORT | ||
@interface MGLImageSource : MGLTileSource | ||
|
||
- (instancetype)initWithIdentifier:(NSString *)identifier imageURL:(NSURL *)imageURL coordinateBounds:(MGLCoordinateBounds)coordinateBounds; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#import "MGLImageSource_Private.h" | ||
|
||
#import "MGLGeometry_Private.h" | ||
#import "MGLSource_Private.h" | ||
#import "MGLTileSource_Private.h" | ||
#import "NSURL+MGLAdditions.h" | ||
|
||
#include <mbgl/style/sources/image_source.hpp> | ||
|
||
@interface MGLImageSource () | ||
|
||
@property (nonatomic, readonly) mbgl::style::ImageSource *rawSource; | ||
|
||
@end | ||
|
||
@implementation MGLImageSource | ||
|
||
- (instancetype)initWithIdentifier:(NSString *)identifier imageURL:(NSURL *)imageURL coordinateBounds:(MGLCoordinateBounds)coordinateBounds { | ||
|
||
const auto coordinates = MGLLatLngBoundsFromCoordinateBounds(coordinateBounds); | ||
std::vector<mbgl::LatLng> coordinatesVector; | ||
coordinatesVector.reserve(4); | ||
coordinatesVector.push_back(coordinates.northwest()); | ||
coordinatesVector.push_back(coordinates.northeast()); | ||
coordinatesVector.push_back(coordinates.southeast()); | ||
coordinatesVector.push_back(coordinates.southwest()); | ||
|
||
auto source = std::make_unique<mbgl::style::ImageSource>(identifier.UTF8String, coordinatesVector); | ||
|
||
source->setURL(imageURL.mgl_URLByStandardizingScheme.absoluteString.UTF8String); | ||
|
||
return self = [super initWithPendingSource:std::move(source)]; | ||
} | ||
|
||
- (mbgl::style::ImageSource *)rawSource { | ||
return (mbgl::style::ImageSource *)super.rawSource; | ||
} | ||
|
||
- (NSString *)attributionHTMLString { | ||
auto attribution = self.rawSource->getAttribution(); | ||
return attribution ? @(attribution->c_str()) : nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import "MGLImageSource.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface MGLImageSource (Private) | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters