summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyle.mm
diff options
context:
space:
mode:
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>()) {