#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class RendererFrontend; namespace style { class Image; class Style; } // namespace style class Map : private util::noncopyable { public: explicit Map(RendererFrontend&, MapObserver&, const MapOptions&, const ResourceOptions&); ~Map(); // Register a callback that will get called (on the render thread) when all resources have // been loaded and a complete render occurs. using StillImageCallback = std::function; void renderStill(StillImageCallback); void renderStill(const CameraOptions&, MapDebugOptions, StillImageCallback); // Triggers a repaint. void triggerRepaint(); style::Style& getStyle(); const style::Style& getStyle() const; void setStyle(std::unique_ptr); // Transition void cancelTransitions(); void setGestureInProgress(bool); bool isGestureInProgress() const; bool isRotating() const; bool isScaling() const; bool isPanning() const; // Camera CameraOptions getCameraOptions(const optional& = {}) const; void jumpTo(const CameraOptions&); void easeTo(const CameraOptions&, const AnimationOptions&); void flyTo(const CameraOptions&, const AnimationOptions&); void moveBy(const ScreenCoordinate&, const AnimationOptions& = {}); void scaleBy(double scale, const optional& anchor, const AnimationOptions& animation = {}); void pitchBy(double pitch, const AnimationOptions& animation = {}); void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {}); CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&, const optional& bearing = {}, const optional& pitch = {}) const; CameraOptions cameraForLatLngs(const std::vector&, const EdgeInsets&, const optional& bearing = {}, const optional& pitch = {}) const; CameraOptions cameraForGeometry(const Geometry&, const EdgeInsets&, const optional& bearing = {}, const optional& pitch = {}) const; LatLngBounds latLngBoundsForCamera(const CameraOptions&) const; LatLngBounds latLngBoundsForCameraUnwrapped(const CameraOptions&) const; /// @name Bounds /// @{ void setBounds(const BoundOptions& options); /// Returns the current map bound options. All optional fields in BoundOptions are set. BoundOptions getBounds() const; /// @} // Map Options void setNorthOrientation(NorthOrientation); void setConstrainMode(ConstrainMode); void setViewportMode(ViewportMode); void setSize(Size); MapOptions getMapOptions() const; //Projection Mode void setProjectionMode(const ProjectionMode&); ProjectionMode getProjectionMode() const; // Projection ScreenCoordinate pixelForLatLng(const LatLng&) const; LatLng latLngForPixel(const ScreenCoordinate&) const; std::vector pixelsForLatLngs(const std::vector&) const; std::vector latLngsForPixels(const std::vector&) const; // Annotations void addAnnotationImage(std::unique_ptr); void removeAnnotationImage(const std::string&); double getTopOffsetPixelsForAnnotationImage(const std::string&); AnnotationID addAnnotation(const Annotation&); void updateAnnotation(AnnotationID, const Annotation&); void removeAnnotation(AnnotationID); // Tile prefetching // // When loading a map, if `PrefetchZoomDelta` is set to any number greater than 0, the map will // first request a tile for `zoom - delta` in a attempt to display a full map at lower // resolution as quick as possible. It will get clamped at the tile source minimum zoom. The // default `delta` is 4. void setPrefetchZoomDelta(uint8_t delta); uint8_t getPrefetchZoomDelta() const; // Debug void setDebug(MapDebugOptions); MapDebugOptions getDebug() const; bool isFullyLoaded() const; void dumpDebugLogs() const; // FreeCameraOptions provides more direct access to the underlying camera entity. // For backwards compatibility the state set using this API must be representable with // `CameraOptions` as well. Parameters are clamped to a valid range or discarded as invalid // if the conversion to the pitch and bearing presentation is ambiguous. For example orientation // can be invalid if it leads to the camera being upside down or the quaternion has zero length. void setFreeCameraOptions(const FreeCameraOptions& camera); FreeCameraOptions getFreeCameraOptions() const; protected: class Impl; const std::unique_ptr impl; // For testing only. Map(std::unique_ptr); }; } // namespace mbgl