MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
map.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/util/chrono.hpp>
7 #include <mbgl/map/mode.hpp>
9 #include <mbgl/util/size.hpp>
11 #include <mbgl/map/camera.hpp>
12 #include <mbgl/util/geometry.hpp>
16 
17 #include <cstdint>
18 #include <string>
19 #include <functional>
20 #include <vector>
21 #include <memory>
22 #include <optional>
23 
24 namespace mbgl {
25 
26 class RendererFrontend;
27 class TransformState;
28 
29 namespace style {
30 class Image;
31 class Style;
32 } // namespace style
33 
34 class Map : private util::noncopyable {
35 public:
36  explicit Map(RendererFrontend&,
37  MapObserver&,
38  const MapOptions&,
39  const ResourceOptions&,
40  const ClientOptions& = ClientOptions());
41  ~Map();
42 
45  using StillImageCallback = std::function<void (std::exception_ptr)>;
48 
51 
53  const style::Style& getStyle() const;
54 
55  void setStyle(std::unique_ptr<style::Style>);
56 
57  // Transition
60  bool isGestureInProgress() const;
61  bool isRotating() const;
62  bool isScaling() const;
63  bool isPanning() const;
64 
65  // Camera
66  CameraOptions getCameraOptions(const std::optional<EdgeInsets>& = std::nullopt) const;
67  void jumpTo(const CameraOptions&);
68  void easeTo(const CameraOptions&, const AnimationOptions&);
69  void flyTo(const CameraOptions&, const AnimationOptions&);
70  void moveBy(const ScreenCoordinate&, const AnimationOptions& = {});
71  void scaleBy(double scale, const std::optional<ScreenCoordinate>& anchor, const AnimationOptions& animation = {});
72  void pitchBy(double pitch, const AnimationOptions& animation = {});
73  void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {});
75  const EdgeInsets&,
76  const std::optional<double>& bearing = std::nullopt,
77  const std::optional<double>& pitch = std::nullopt) const;
78  CameraOptions cameraForLatLngs(const std::vector<LatLng>&,
79  const EdgeInsets&,
80  const std::optional<double>& bearing = std::nullopt,
81  const std::optional<double>& pitch = std::nullopt) const;
83  const EdgeInsets&,
84  const std::optional<double>& bearing = std::nullopt,
85  const std::optional<double>& pitch = std::nullopt) const;
88 
91 
92  void setBounds(const BoundOptions& options);
93 
96 
98 
99  // Map Options
103  void setSize(Size);
105 
106  //Projection Mode
109 
110  // Projection
113  std::vector<ScreenCoordinate> pixelsForLatLngs(const std::vector<LatLng>&) const;
114  std::vector<LatLng> latLngsForPixels(const std::vector<ScreenCoordinate>&) const;
115 
116  // Transform
117  TransformState getTransfromState() const;
118 
119  // Annotations
120  void addAnnotationImage(std::unique_ptr<style::Image>);
123 
127 
128  // Tile prefetching
129  //
134  void setPrefetchZoomDelta(uint8_t delta);
135  uint8_t getPrefetchZoomDelta() const;
136 
137  // Debug
140 
141  bool isFullyLoaded() const;
142  void dumpDebugLogs() const;
143 
151 
152 protected:
153  class Impl;
154  const std::unique_ptr<Impl> impl;
155 
156  // For testing only.
157  Map(std::unique_ptr<Impl>);
158 };
159 
160 } // namespace mbgl
Holds values for client options.
The distance on each side between a rectangle and a rectangle within.
Definition: geo.hpp:187
Holds values for Map options.
Definition: map_options.hpp:14
void setGestureInProgress(bool)
void flyTo(const CameraOptions &, const AnimationOptions &)
std::function< void(std::exception_ptr)> StillImageCallback
Definition: map.hpp:45
bool isPanning() const
CameraOptions cameraForLatLngBounds(const LatLngBounds &, const EdgeInsets &, const std::optional< double > &bearing=std::nullopt, const std::optional< double > &pitch=std::nullopt) const
std::vector< ScreenCoordinate > pixelsForLatLngs(const std::vector< LatLng > &) const
void setStyle(std::unique_ptr< style::Style >)
CameraOptions getCameraOptions(const std::optional< EdgeInsets > &=std::nullopt) const
ProjectionMode getProjectionMode() const
void dumpDebugLogs() const
void jumpTo(const CameraOptions &)
void pitchBy(double pitch, const AnimationOptions &animation={})
void setFreeCameraOptions(const FreeCameraOptions &camera)
void moveBy(const ScreenCoordinate &, const AnimationOptions &={})
double getTopOffsetPixelsForAnnotationImage(const std::string &)
LatLngBounds latLngBoundsForCamera(const CameraOptions &) const
void setConstrainMode(ConstrainMode)
void rotateBy(const ScreenCoordinate &first, const ScreenCoordinate &second, const AnimationOptions &={})
void setSize(Size)
void cancelTransitions()
CameraOptions cameraForGeometry(const Geometry< double > &, const EdgeInsets &, const std::optional< double > &bearing=std::nullopt, const std::optional< double > &pitch=std::nullopt) const
void setPrefetchZoomDelta(uint8_t delta)
AnnotationID addAnnotation(const Annotation &)
CameraOptions cameraForLatLngs(const std::vector< LatLng > &, const EdgeInsets &, const std::optional< double > &bearing=std::nullopt, const std::optional< double > &pitch=std::nullopt) const
void removeAnnotationImage(const std::string &)
void triggerRepaint()
Triggers a repaint.
LatLng latLngForPixel(const ScreenCoordinate &) const
bool isScaling() const
void renderStill(const CameraOptions &, MapDebugOptions, StillImageCallback)
const style::Style & getStyle() const
void scaleBy(double scale, const std::optional< ScreenCoordinate > &anchor, const AnimationOptions &animation={})
Map(std::unique_ptr< Impl >)
bool isRotating() const
void setDebug(MapDebugOptions)
Map(RendererFrontend &, MapObserver &, const MapOptions &, const ResourceOptions &, const ClientOptions &=ClientOptions())
MapOptions getMapOptions() const
uint8_t getPrefetchZoomDelta() const
void updateAnnotation(AnnotationID, const Annotation &)
bool isGestureInProgress() const
void setNorthOrientation(NorthOrientation)
bool isFullyLoaded() const
void setViewportMode(ViewportMode)
TransformState getTransfromState() const
void setBounds(const BoundOptions &options)
void easeTo(const CameraOptions &, const AnimationOptions &)
void removeAnnotation(AnnotationID)
std::vector< LatLng > latLngsForPixels(const std::vector< ScreenCoordinate > &) const
style::Style & getStyle()
BoundOptions getBounds() const
Returns the current map bound options. All optional fields in BoundOptions are set.
void addAnnotationImage(std::unique_ptr< style::Image >)
ScreenCoordinate pixelForLatLng(const LatLng &) const
FreeCameraOptions getFreeCameraOptions() const
void setProjectionMode(const ProjectionMode &)
MapDebugOptions getDebug() const
LatLngBounds latLngBoundsForCameraUnwrapped(const CameraOptions &) const
const std::unique_ptr< Impl > impl
Definition: map.hpp:153
void renderStill(StillImageCallback)
Holds values for resource options.
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
constexpr ImageType Image
Definition: type.hpp:93
Definition: actor.hpp:15
mapbox::geometry::point< double > ScreenCoordinate
Definition: geo.hpp:20
uint64_t AnnotationID
Definition: annotation.hpp:14
MapDebugOptions
Definition: mode.hpp:37
mapbox::geometry::geometry< T > Geometry
Definition: geometry.hpp:42
ViewportMode
Definition: mode.hpp:32
NorthOrientation
Definition: geo.hpp:179
ConstrainMode
Definition: mode.hpp:24
variant< SymbolAnnotation, LineAnnotation, FillAnnotation > Annotation
Definition: annotation.hpp:68
Holds options to limit what parts of a map are visible. All fields are optional.
Holds values for Axonometric rendering. All fields are optional.