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

Commit

Permalink
[core] Restored shape annotation z-order
Browse files Browse the repository at this point in the history
Shapes are once again always added to the top z-index.

Fixes #5691.

Cherry-picked from 74fe96d.
  • Loading branch information
1ec5 committed Jul 18, 2016
1 parent ede1e71 commit 8179f2f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.

## master

* Fixed an issue causing overlapping polylines and polygons to be drawn in undefined z-order. Shapes are always drawn in the order they are added to the map, from the oldest on the bottom to the newest on the top. ([#5710](https://github.com/mapbox/mapbox-gl-native/pull/5710))

## 3.3.0

### Styles and data
Expand Down
1 change: 1 addition & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog for Mapbox macOS SDK

## master
* Fixed an issue causing overlapping polylines and polygons to be drawn in undefined z-order. Shapes are always drawn in the order they are added to the map, from the oldest on the bottom to the newest on the top. ([#5710](https://github.com/mapbox/mapbox-gl-native/pull/5710))
* Replaced the wireframe debug mask with an overdraw visualization debug mask to match Mapbox GL JS’s overdraw inspector. ([#5403](https://github.com/mapbox/mapbox-gl-native/pull/5403))
* Improved the design of the generated API documentation. ([#5306](https://github.com/mapbox/mapbox-gl-native/pull/5306))

Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/annotation/annotation_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ class AnnotationManager : private util::noncopyable {
AnnotationID nextID = 0;

using SymbolAnnotationTree = boost::geometry::index::rtree<std::shared_ptr<const SymbolAnnotationImpl>, boost::geometry::index::rstar<16, 4>>;
using SymbolAnnotationMap = std::unordered_map<AnnotationID, std::shared_ptr<SymbolAnnotationImpl>>;
using ShapeAnnotationMap = std::unordered_map<AnnotationID, std::unique_ptr<ShapeAnnotationImpl>>;
// Unlike std::unordered_map, std::map is guaranteed to sort by AnnotationID, ensuring that older annotations are below newer annotations.
// <https://github.com/mapbox/mapbox-gl-native/issues/5691>
using SymbolAnnotationMap = std::map<AnnotationID, std::shared_ptr<SymbolAnnotationImpl>>;
using ShapeAnnotationMap = std::map<AnnotationID, std::unique_ptr<ShapeAnnotationImpl>>;

SymbolAnnotationTree symbolTree;
SymbolAnnotationMap symbolAnnotations;
Expand Down
15 changes: 15 additions & 0 deletions test/api/annotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ TEST(Annotations, FillAnnotation) {
test.checkRendering("fill_annotation");
}

TEST(Annotations, OverlappingFillAnnotation) {
AnnotationTest test;

Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
FillAnnotation underlaidAnnotation { polygon };
underlaidAnnotation.color = { { 0, 255, 0, 1 } };
FillAnnotation overlaidAnnotation { polygon };
overlaidAnnotation.color = { { 255, 0, 0, 1 } };

test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotation(underlaidAnnotation);
test.map.addAnnotation(overlaidAnnotation);
test.checkRendering("overlapping_fill_annotation");
}

TEST(Annotations, StyleSourcedShapeAnnotation) {
AnnotationTest test;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8179f2f

Please sign in to comment.