diff options
Diffstat (limited to 'src/mbgl/style/style_parser.cpp')
-rw-r--r-- | src/mbgl/style/style_parser.cpp | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 83a113f885..c2aa115fa4 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -36,20 +36,30 @@ void StyleParser::parse(JSVal document) { if (document.HasMember("layers")) { parseLayers(document["layers"]); + // create shape annotations source + const std::string& shapeID = AnnotationManager::ShapeLayerID; + + util::ptr<Source> shapeAnnotationsSource = std::make_shared<Source>(); + sourcesMap.emplace(shapeID, shapeAnnotationsSource); + sources.emplace_back(shapeAnnotationsSource); + shapeAnnotationsSource->info.type = SourceType::Annotations; + shapeAnnotationsSource->info.source_id = shapeID; + // create point annotations layer - // - const std::string& id = AnnotationManager::layerID; + const std::string& pointID = AnnotationManager::PointLayerID; - std::map<ClassID, ClassProperties> paints; - util::ptr<StyleLayer> annotations = std::make_shared<StyleLayer>(id, std::move(paints)); - annotations->type = StyleLayerType::Symbol; - layersMap.emplace(id, std::pair<JSVal, util::ptr<StyleLayer>> { JSVal(id), annotations }); - layers.emplace_back(annotations); + std::map<ClassID, ClassProperties> pointPaints; + util::ptr<StyleLayer> pointAnnotationsLayer = std::make_shared<StyleLayer>(pointID, std::move(pointPaints)); + pointAnnotationsLayer->type = StyleLayerType::Symbol; + layersMap.emplace(pointID, std::pair<JSVal, util::ptr<StyleLayer>> { JSVal(pointID), pointAnnotationsLayer }); + layers.emplace_back(pointAnnotationsLayer); - util::ptr<StyleBucket> pointBucket = std::make_shared<StyleBucket>(annotations->type); - pointBucket->name = annotations->id; - pointBucket->source_layer = annotations->id; + // create point annotations symbol bucket + util::ptr<StyleBucket> pointBucket = std::make_shared<StyleBucket>(pointAnnotationsLayer->type); + pointBucket->name = pointAnnotationsLayer->id; + pointBucket->source_layer = pointAnnotationsLayer->id; + // build up point annotations style rapidjson::Document d; rapidjson::Value iconImage(rapidjson::kObjectType); iconImage.AddMember("icon-image", "{sprite}", d.GetAllocator()); @@ -58,14 +68,14 @@ void StyleParser::parse(JSVal document) { iconOverlap.AddMember("icon-allow-overlap", true, d.GetAllocator()); parseLayout(iconOverlap, pointBucket); - util::ptr<Source> source = std::make_shared<Source>(); - sourcesMap.emplace(id, source); - sources.emplace_back(source); - source->info.type = SourceType::Annotations; - pointBucket->source = source; - annotations->bucket = pointBucket; - // - // end point annotations + // create point annotations source & connect to bucket & layer + util::ptr<Source> pointAnnotationsSource = std::make_shared<Source>(); + sourcesMap.emplace(pointID, pointAnnotationsSource); + sources.emplace_back(pointAnnotationsSource); + pointAnnotationsSource->info.type = SourceType::Annotations; + pointAnnotationsSource->info.source_id = pointID; + pointBucket->source = pointAnnotationsSource; + pointAnnotationsLayer->bucket = pointBucket; } if (document.HasMember("sprite")) { |