summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyle.mm
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-08-15 15:09:02 +0200
committerFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-08-18 14:26:04 +0200
commit5d307d098b29d2cd0a18db802e4199606d0689af (patch)
tree6c91bf9d0fd792d3689eb0e9e9e28d9c2038eb14 /platform/darwin/src/MGLStyle.mm
parent106dd460fe4f09336470ee46e3e9759d331ec20c (diff)
downloadqtlocation-mapboxgl-5d307d098b29d2cd0a18db802e4199606d0689af.tar.gz
[ios, macos] Fixes #5975 Add source getter to MGLStyle
Diffstat (limited to 'platform/darwin/src/MGLStyle.mm')
-rw-r--r--platform/darwin/src/MGLStyle.mm29
1 files changed, 29 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index d40bce063d..ae52dc3f2b 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -22,6 +22,8 @@
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
+#include <mbgl/style/sources/vector_source.hpp>
+#include <mbgl/style/sources/raster_source.hpp>
#include <mbgl/mbgl.hpp>
@interface MGLStyle()
@@ -104,6 +106,33 @@ static NSURL *MGLStyleURL_emerald;
return styleLayer;
}
+- (MGLSource *)sourceWithIdentifier:(NSString *)identifier
+{
+ auto s = self.mapView.mbglMap->getSource(identifier.UTF8String);
+
+ Class clazz = [self classFromSource:s];
+
+ MGLSource *source = [[clazz alloc] init];
+ source.sourceIdentifier = identifier;
+ source.source = s;
+
+ return source;
+}
+
+- (Class)classFromSource:(mbgl::style::Source *)source
+{
+ if (dynamic_cast<mbgl::style::VectorSource *>(source)) {
+ return MGLVectorSource.class;
+ } else if (dynamic_cast<mbgl::style::GeoJSONSource *>(source)) {
+ return MGLGeoJSONSource.class;
+ } else if (dynamic_cast<mbgl::style::RasterSource *>(source)) {
+ return MGLRasterSource.class;
+ }
+
+ [NSException raise:@"Source type not handled" format:@""];
+ return Nil;
+}
+
- (Class)classFromLayer:(mbgl::style::Layer *)layer
{
if (layer->is<mbgl::style::FillLayer>()) {