[core] Pull annotation typedefs to own header; add AnnotationID
This commit is contained in:
20
include/mbgl/annotation/annotation.hpp
Normal file
20
include/mbgl/annotation/annotation.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef MBGL_ANNOTATION
|
||||
#define MBGL_ANNOTATION
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
enum class AnnotationType : uint8_t {
|
||||
Any = 0,
|
||||
Point = 1 << 0,
|
||||
Shape = 1 << 1,
|
||||
};
|
||||
|
||||
using AnnotationID = uint32_t;
|
||||
using AnnotationIDs = std::vector<AnnotationID>;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,14 +1,16 @@
|
||||
#ifndef MBGL_ANNOTATION_SHAPE_ANNOTATION
|
||||
#define MBGL_ANNOTATION_SHAPE_ANNOTATION
|
||||
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/annotation/annotation.hpp>
|
||||
#include <mbgl/style/style_properties.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using AnnotationSegment = std::vector<LatLng>;
|
||||
using AnnotationSegments = std::vector<AnnotationSegment>;
|
||||
|
||||
class ShapeAnnotation {
|
||||
public:
|
||||
inline ShapeAnnotation(const AnnotationSegments& segments_, const StyleProperties& styleProperties_)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
#include <mbgl/annotation/annotation.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -31,12 +32,6 @@ namespace util {
|
||||
template <class T> class Thread;
|
||||
}
|
||||
|
||||
enum class AnnotationType : uint8_t {
|
||||
Any = 0,
|
||||
Point = 1 << 0,
|
||||
Shape = 1 << 1,
|
||||
};
|
||||
|
||||
struct EdgeInsets {
|
||||
double top = 0;
|
||||
double left = 0;
|
||||
@@ -44,10 +39,6 @@ struct EdgeInsets {
|
||||
double right = 0;
|
||||
};
|
||||
|
||||
using AnnotationIDs = std::vector<uint32_t>;
|
||||
using AnnotationSegment = std::vector<LatLng>;
|
||||
using AnnotationSegments = std::vector<AnnotationSegment>;
|
||||
|
||||
class Map : private util::noncopyable {
|
||||
friend class View;
|
||||
|
||||
@@ -147,13 +138,13 @@ public:
|
||||
void setDefaultPointAnnotationSymbol(const std::string&);
|
||||
double getTopOffsetPixelsForAnnotationSymbol(const std::string&);
|
||||
|
||||
uint32_t addPointAnnotation(const PointAnnotation&);
|
||||
AnnotationID addPointAnnotation(const PointAnnotation&);
|
||||
AnnotationIDs addPointAnnotations(const std::vector<PointAnnotation>&);
|
||||
|
||||
uint32_t addShapeAnnotation(const ShapeAnnotation&);
|
||||
AnnotationID addShapeAnnotation(const ShapeAnnotation&);
|
||||
AnnotationIDs addShapeAnnotations(const std::vector<ShapeAnnotation>&);
|
||||
|
||||
void removeAnnotation(uint32_t);
|
||||
void removeAnnotation(AnnotationID);
|
||||
void removeAnnotations(const AnnotationIDs&);
|
||||
|
||||
AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const AnnotationType& = AnnotationType::Any);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MBGL_MAP_ANNOTATIONS
|
||||
#define MBGL_MAP_ANNOTATIONS
|
||||
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/annotation/annotation.hpp>
|
||||
#include <mbgl/map/geometry_tile.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/style/style_properties.hpp>
|
||||
|
||||
@@ -349,7 +349,7 @@ double Map::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) {
|
||||
return context->invokeSync<double>(&MapContext::getTopOffsetPixelsForAnnotationSymbol, symbol);
|
||||
}
|
||||
|
||||
uint32_t Map::addPointAnnotation(const PointAnnotation& annotation) {
|
||||
AnnotationID Map::addPointAnnotation(const PointAnnotation& annotation) {
|
||||
return addPointAnnotations({ annotation }).front();
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ AnnotationIDs Map::addPointAnnotations(const std::vector<PointAnnotation>& annot
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t Map::addShapeAnnotation(const ShapeAnnotation& annotation) {
|
||||
AnnotationID Map::addShapeAnnotation(const ShapeAnnotation& annotation) {
|
||||
return addShapeAnnotations({ annotation }).front();
|
||||
}
|
||||
|
||||
@@ -369,20 +369,20 @@ AnnotationIDs Map::addShapeAnnotations(const std::vector<ShapeAnnotation>& annot
|
||||
return result;
|
||||
}
|
||||
|
||||
void Map::removeAnnotation(uint32_t annotation) {
|
||||
void Map::removeAnnotation(AnnotationID annotation) {
|
||||
removeAnnotations({ annotation });
|
||||
}
|
||||
|
||||
void Map::removeAnnotations(const std::vector<uint32_t>& annotations) {
|
||||
void Map::removeAnnotations(const AnnotationIDs& annotations) {
|
||||
data->getAnnotationManager()->removeAnnotations(annotations, getMaxZoom());
|
||||
update(Update::Annotations);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> Map::getAnnotationsInBounds(const LatLngBounds& bounds, const AnnotationType& type) {
|
||||
AnnotationIDs Map::getAnnotationsInBounds(const LatLngBounds& bounds, const AnnotationType& type) {
|
||||
return data->getAnnotationManager()->getAnnotationsInBounds(bounds, getMaxZoom(), type);
|
||||
}
|
||||
|
||||
LatLngBounds Map::getBoundsForAnnotations(const std::vector<uint32_t>& annotations) {
|
||||
LatLngBounds Map::getBoundsForAnnotations(const AnnotationIDs& annotations) {
|
||||
return data->getAnnotationManager()->getBoundsForAnnotations(annotations);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user