diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2015-03-17 17:30:24 -0700 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-03-17 17:30:24 -0700 |
commit | e049ce6df13c3ad77e9e2ecb2e1afe2992384a35 (patch) | |
tree | 17c21487d53639e3cdf3d6fa9cf78a249a8a67a1 /src/mbgl/style | |
parent | 1ce51a17e7de5d6a02346efce1539ff7f36e0a6d (diff) | |
download | qtlocation-mapboxgl-e049ce6df13c3ad77e9e2ecb2e1afe2992384a35.tar.gz |
refs #893 #992: point annotations API
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/style_parser.cpp | 31 | ||||
-rw-r--r-- | src/mbgl/style/types.hpp | 4 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 25bf9bf665..f2bd8e6c88 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -29,6 +29,37 @@ void StyleParser::parse(JSVal document) { if (document.HasMember("layers")) { root = createLayers(document["layers"]); parseLayers(); + + // create point annotations layer + // + std::string id = util::ANNOTATIONS_POINTS_LAYER_ID; + + std::map<ClassID, ClassProperties> paints; + util::ptr<StyleLayer> annotations = std::make_shared<StyleLayer>(id, std::move(paints)); + annotations->type = StyleLayerType::Symbol; + layers.emplace(id, std::pair<JSVal, util::ptr<StyleLayer>> { JSVal(id), annotations }); + root->layers.emplace_back(annotations); + + util::ptr<StyleBucket> pointBucket = std::make_shared<StyleBucket>(annotations->type); + pointBucket->name = annotations->id; + pointBucket->source_layer = annotations->id; + + rapidjson::Document d; + rapidjson::Value iconImage(rapidjson::kObjectType); + iconImage.AddMember("icon-image", "{sprite}", d.GetAllocator()); + parseLayout(iconImage, pointBucket); + rapidjson::Value iconOverlap(rapidjson::kObjectType); + iconOverlap.AddMember("icon-allow-overlap", true, d.GetAllocator()); + parseLayout(iconOverlap, pointBucket); + + SourceInfo& info = sources.emplace(id, std::make_shared<StyleSource>()).first->second->info; + info.type = SourceType::Annotations; + + auto source_it = sources.find(id); + pointBucket->style_source = source_it->second; + annotations->bucket = pointBucket; + // + // end point annotations } if (document.HasMember("sprite")) { diff --git a/src/mbgl/style/types.hpp b/src/mbgl/style/types.hpp index 78938a2823..3b24d63998 100644 --- a/src/mbgl/style/types.hpp +++ b/src/mbgl/style/types.hpp @@ -48,7 +48,8 @@ enum class SourceType : uint8_t { Vector, Raster, GeoJSON, - Video + Video, + Annotations }; MBGL_DEFINE_ENUM_CLASS(SourceTypeClass, SourceType, { @@ -56,6 +57,7 @@ MBGL_DEFINE_ENUM_CLASS(SourceTypeClass, SourceType, { { SourceType::Raster, "raster" }, { SourceType::GeoJSON, "geojson" }, { SourceType::Video, "video" }, + { SourceType::Annotations, "annotations" }, }); // ------------------------------------------------------------------------------------------------- |