Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
fix problems with multiple point annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Jun 1, 2015
1 parent 8626f91 commit b51f5e8
Showing 1 changed file with 47 additions and 27 deletions.
74 changes: 47 additions & 27 deletions src/mbgl/map/annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ AnnotationManager::addAnnotations(const AnnotationType type,
std::vector<std::vector<vec2<double>>> projectedShape;
projectedShape.reserve(shape.size());

const uint32_t annotationID = nextID();

for (size_t l = 0; l < shape.size(); ++l) {
auto& line = shape[l];

Expand All @@ -120,37 +118,59 @@ AnnotationManager::addAnnotations(const AnnotationType type,
// projection conversion into unit space
const auto pp = projectPoint(point);

projectedLine.push_back(pp);
}
if (type == AnnotationType::Point) {
const uint32_t pointAnnotationID = nextID();

projectedShape.push_back(projectedLine);
}
// at render time we style the point according to its {sprite} field
std::unordered_map<std::string, std::string> pointFeatureProperties;
const std::string& symbol = annotationsProperties.at("symbols")[p];
if (symbol.length()) {
pointFeatureProperties.emplace("sprite", symbol);
} else {
pointFeatureProperties.emplace("sprite", defaultPointAnnotationSymbol);
}

std::unordered_map<std::string, std::string> featureProperties;
// add individual point tile feature
auto featureAffectedTiles = addTileFeature(
pointAnnotationID,
AnnotationSegments({{ point }}),
std::vector<std::vector<vec2<double>>>({{ pp }}),
AnnotationType::Point,
{{ }},
pointFeatureProperties,
maxZoom
);

if (type == AnnotationType::Point) {
// at render time we style the point according to its {sprite} field
const std::string& symbol = annotationsProperties.at("symbols")[s];
if (symbol.length()) {
featureProperties.emplace("sprite", symbol);
} else {
featureProperties.emplace("sprite", defaultPointAnnotationSymbol);
std::copy(featureAffectedTiles.begin(), featureAffectedTiles.end(), std::inserter(affectedTiles, affectedTiles.begin()));

annotationIDs.push_back(pointAnnotationID);
} else {
projectedLine.push_back(pp);
}
}

if (type == AnnotationType::Shape) {
projectedShape.push_back(projectedLine);
}
}

auto featureAffectedTiles = addTileFeature(
annotationID,
shape,
projectedShape,
type,
styleProperties[s],
featureProperties,
maxZoom
);
if (type == AnnotationType::Shape) {
const uint32_t shapeAnnotationID = nextID();

auto featureAffectedTiles = addTileFeature(
shapeAnnotationID,
shape,
projectedShape,
AnnotationType::Shape,
styleProperties[s],
{{ }},
maxZoom
);

std::copy(featureAffectedTiles.begin(), featureAffectedTiles.end(), std::inserter(affectedTiles, affectedTiles.begin()));
std::copy(featureAffectedTiles.begin(), featureAffectedTiles.end(), std::inserter(affectedTiles, affectedTiles.begin()));

annotationIDs.push_back(annotationID);
annotationIDs.push_back(shapeAnnotationID);
}
}

// Tile:IDs that need refreshed and the annotation identifiers held onto by the client.
Expand Down Expand Up @@ -286,8 +306,8 @@ AnnotationManager::addPointAnnotations(const AnnotationSegment& points,
const AnnotationsProperties& annotationsProperties,
const MapData& data) {
return addAnnotations(AnnotationType::Point,
{ { points } },
{ defaultStyleProperties<SymbolProperties>() },
{{ points }},
{{ }},
annotationsProperties,
data);
}
Expand Down

0 comments on commit b51f5e8

Please sign in to comment.