#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class FileSource; class View; class SpriteImage; struct CameraOptions; struct AnimationOptions; namespace style { class Source; class Layer; } // namespace style class Map : private util::noncopyable { public: explicit Map(View&, FileSource&, MapMode mapMode = MapMode::Continuous, GLContextMode contextMode = GLContextMode::Unique, ConstrainMode constrainMode = ConstrainMode::HeightOnly, ViewportMode viewportMode = ViewportMode::Default); ~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 callback); // Main render function. void render(); // Notifies the Map that the state has changed and an update might be necessary. void update(Update update); // Styling void addClass(const std::string&, const style::TransitionOptions& = {}); void removeClass(const std::string&, const style::TransitionOptions& = {}); void setClasses(const std::vector&, const style::TransitionOptions& = {}); bool hasClass(const std::string&) const; std::vector getClasses() const; void setStyleURL(const std::string&); void setStyleJSON(const std::string&); std::string getStyleURL() const; std::string getStyleJSON() const; // Transition void cancelTransitions(); void setGestureInProgress(bool); bool isGestureInProgress() const; bool isRotating() const; bool isScaling() const; bool isPanning() const; // Camera CameraOptions getCameraOptions(optional) const; void jumpTo(const CameraOptions&); void easeTo(const CameraOptions&, const AnimationOptions&); void flyTo(const CameraOptions&, const AnimationOptions&); // Position void moveBy(const ScreenCoordinate&, const Duration& = Duration::zero()); void setLatLng(const LatLng&, optional, const Duration& = Duration::zero()); void setLatLng(const LatLng&, optional, const Duration& = Duration::zero()); void setLatLng(const LatLng&, const Duration& = Duration::zero()); LatLng getLatLng(optional = {}) const; void resetPosition(optional = {}); // Scale void scaleBy(double ds, optional = {}, const Duration& = Duration::zero()); void setScale(double scale, optional = {}, const Duration& = Duration::zero()); double getScale() const; void setZoom(double zoom, const Duration& = Duration::zero()); void setZoom(double zoom, optional, const Duration& = Duration::zero()); double getZoom() const; void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero()); void setLatLngZoom(const LatLng&, double zoom, optional, const Duration& = Duration::zero()); CameraOptions cameraForLatLngBounds(const LatLngBounds&, optional) const; CameraOptions cameraForLatLngs(const std::vector&, optional) const; void resetZoom(); void setMinZoom(const double minZoom); double getMinZoom() const; void setMaxZoom(const double maxZoom); double getMaxZoom() const; // Rotation void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& = Duration::zero()); void setBearing(double degrees, const Duration& = Duration::zero()); void setBearing(double degrees, optional, const Duration& = Duration::zero()); void setBearing(double degrees, optional, const Duration& = Duration::zero()); double getBearing() const; void resetNorth(const Duration& = Milliseconds(500)); void resetNorth(optional, const Duration& = Milliseconds(500)); // Pitch void setPitch(double pitch, const Duration& = Duration::zero()); void setPitch(double pitch, optional, const Duration& = Duration::zero()); double getPitch() const; // North Orientation void setNorthOrientation(NorthOrientation); NorthOrientation getNorthOrientation() const; // Constrain mode void setConstrainMode(ConstrainMode); ConstrainMode getConstrainMode() const; // Viewport mode void setViewportMode(ViewportMode); ViewportMode getViewportMode() const; // Size uint16_t getWidth() const; uint16_t getHeight() const; // Projection double getMetersPerPixelAtLatitude(double lat, double zoom) const; ProjectedMeters projectedMetersForLatLng(const LatLng&) const; LatLng latLngForProjectedMeters(const ProjectedMeters&) const; ScreenCoordinate pixelForLatLng(const LatLng&) const; LatLng latLngForPixel(const ScreenCoordinate&) const; // Annotations void addAnnotationIcon(const std::string&, std::shared_ptr); void removeAnnotationIcon(const std::string&); double getTopOffsetPixelsForAnnotationIcon(const std::string&); AnnotationID addAnnotation(const Annotation&); void updateAnnotation(AnnotationID, const Annotation&); void removeAnnotation(AnnotationID); // Sources style::Source* getSource(const std::string& sourceID); void addSource(std::unique_ptr); void removeSource(const std::string& sourceID); // Layers style::Layer* getLayer(const std::string& layerID); void addLayer(std::unique_ptr, const optional& beforeLayerID = {}); void removeLayer(const std::string& layerID); // Feature queries std::vector queryRenderedFeatures(const ScreenCoordinate&, const optional>& layerIDs = {}); std::vector queryRenderedFeatures(const ScreenBox&, const optional>& layerIDs = {}); AnnotationIDs queryPointAnnotations(const ScreenBox&); // Memory void setSourceTileCacheSize(size_t); void onLowMemory(); // Debug void setDebug(MapDebugOptions); void cycleDebugOptions(); MapDebugOptions getDebug() const; bool isFullyLoaded() const; void dumpDebugLogs() const; private: class Impl; const std::unique_ptr impl; }; } // namespace mbgl