diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-12-06 11:48:36 +0100 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2016-12-12 09:05:23 -0500 |
commit | e9f101a52f626744991ee73c3ced9c48bc013a51 (patch) | |
tree | 2e2e36e3db3a58d5f81366bc12ce539189817044 /platform/ios | |
parent | a32e62cb0f3a6d9654712ab93380b15db7b337aa (diff) | |
download | qtlocation-mapboxgl-e9f101a52f626744991ee73c3ced9c48bc013a51.tar.gz |
[ios, macos] handle duplicate layer error
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 3c019d4726..fad3540139 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -5353,9 +5353,13 @@ void MGLFinishCustomStyleLayer(void *context) { NSAssert(identifier, @"Style layer needs an identifier"); MGLCustomStyleLayerHandlers *context = new MGLCustomStyleLayerHandlers(preparation, drawing, completion); - _mbglMap->addLayer(std::make_unique<mbgl::style::CustomLayer>(identifier.UTF8String, MGLPrepareCustomStyleLayer, - MGLDrawCustomStyleLayer, MGLFinishCustomStyleLayer, context), - otherIdentifier ? mbgl::optional<std::string>(otherIdentifier.UTF8String) : mbgl::optional<std::string>()); + try { + _mbglMap->addLayer(std::make_unique<mbgl::style::CustomLayer>(identifier.UTF8String, MGLPrepareCustomStyleLayer, + MGLDrawCustomStyleLayer, MGLFinishCustomStyleLayer, context), + otherIdentifier ? mbgl::optional<std::string>(otherIdentifier.UTF8String) : mbgl::optional<std::string>()); + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } } - (void)removeCustomStyleLayerWithIdentifier:(NSString *)identifier |