summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLVectorSource.mm
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-09-22 17:30:47 -0700
committerGitHub <noreply@github.com>2016-09-22 17:30:47 -0700
commit3ddb8dfc86753120d2ea2c3befdf2430c1c56562 (patch)
treebc241d8c66ea7f78ae4728f9644673e8994e1295 /platform/darwin/src/MGLVectorSource.mm
parent08c08f6705d168f0bc7cde251cdacb2c4a53bb7a (diff)
downloadqtlocation-mapboxgl-3ddb8dfc86753120d2ea2c3befdf2430c1c56562.tar.gz
[ios, macos] Add tile template option to raster and vector sources
A new MGLTileSet class that wraps all available core Tileset options can be created and passed into the sources. The sources pass that tileset object along to core.
Diffstat (limited to 'platform/darwin/src/MGLVectorSource.mm')
-rw-r--r--platform/darwin/src/MGLVectorSource.mm31
1 files changed, 28 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLVectorSource.mm b/platform/darwin/src/MGLVectorSource.mm
index d0c9b0126a..2ab9627ef5 100644
--- a/platform/darwin/src/MGLVectorSource.mm
+++ b/platform/darwin/src/MGLVectorSource.mm
@@ -1,6 +1,8 @@
#import "MGLVectorSource.h"
#import "MGLSource_Private.h"
+#import "MGLTileSet_Private.h"
+#import "NSURL+MGLAdditions.h"
#include <mbgl/style/sources/vector_source.hpp>
@@ -8,16 +10,39 @@
static NSString *MGLVectorSourceType = @"vector";
-- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url {
- if (self = [super initWithSourceIdentifier:sourceIdentifier]) {
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url
+{
+ if (self = [super initWithSourceIdentifier:sourceIdentifier])
+ {
_URL = url;
}
return self;
}
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier tileSet:(MGLTileSet *)tileSet
+{
+ if (self = [super initWithSourceIdentifier:sourceIdentifier])
+ {
+ _tileSet = tileSet;
+ }
+ return self;
+}
+
- (std::unique_ptr<mbgl::style::Source>)mbglSource
{
- auto source = std::make_unique<mbgl::style::VectorSource>(self.sourceIdentifier.UTF8String, self.URL.absoluteString.UTF8String);
+ std::unique_ptr<mbgl::style::VectorSource> source;
+
+ if (self.URL)
+ {
+ source = std::make_unique<mbgl::style::VectorSource>(self.sourceIdentifier.UTF8String,
+ self.URL.mgl_URLByStandardizingScheme.absoluteString.UTF8String);
+ }
+ else
+ {
+ source = std::make_unique<mbgl::style::VectorSource>(self.sourceIdentifier.UTF8String,
+ self.tileSet.mbglTileset);
+ }
+
return std::move(source);
}