#ifndef MBGL_MAP_MAP #define MBGL_MAP_MAP #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class FileSource; class View; class MapData; class MapContext; class StillImage; class SpriteImage; class Transform; class PointAnnotation; class ShapeAnnotation; struct CameraOptions; namespace util { template class Thread; } struct EdgeInsets { double top = 0; double left = 0; double bottom = 0; double right = 0; }; class Map : private util::noncopyable { friend class View; public: explicit Map(View&, FileSource&, MapMode mapMode = MapMode::Continuous, GLContextMode contextMode = GLContextMode::Unique); ~Map(); // Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed. void pause(); bool isPaused(); // Resumes a paused render thread void resume(); // 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); // Triggers a synchronous render. void renderSync(); // Notifies the Map thread that the state has changed and an update might be necessary. void update(Update update); // Styling void addClass(const std::string&); void removeClass(const std::string&); bool hasClass(const std::string&) const; void setClasses(const std::vector&); std::vector getClasses() const; void setDefaultFadeDuration(const Duration&); Duration getDefaultFadeDuration() const; void setDefaultTransitionDuration(const Duration&); Duration getDefaultTransitionDuration() const; void setDefaultTransitionDelay(const Duration&); Duration getDefaultTransitionDelay() const; void setStyleURL(const std::string& url); void setStyleJSON(const std::string& json, const std::string& base = ""); 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 void jumpTo(const CameraOptions&); void easeTo(const CameraOptions&); // Position void moveBy(const PrecisionPoint&, const Duration& = Duration::zero()); void setLatLng(const LatLng&, const PrecisionPoint&, const Duration& = Duration::zero()); void setLatLng(const LatLng&, const Duration& = Duration::zero()); LatLng getLatLng() const; void resetPosition(); // Scale void scaleBy(double ds, const PrecisionPoint& = { 0, 0 }, const Duration& = Duration::zero()); void setScale(double scale, const PrecisionPoint& = { 0, 0 }, const Duration& = Duration::zero()); double getScale() const; void setZoom(double zoom, const Duration& = Duration::zero()); double getZoom() const; void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero()); CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&); CameraOptions cameraForLatLngs(const std::vector&, const EdgeInsets&); void resetZoom(); double getMinZoom() const; double getMaxZoom() const; // Rotation void rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& = Duration::zero()); void setBearing(double degrees, const Duration& = Duration::zero()); void setBearing(double degrees, const PrecisionPoint&); double getBearing() const; void resetNorth(); // Pitch void setPitch(double pitch, const Duration& = Duration::zero()); double getPitch() const; // Size uint16_t getWidth() const; uint16_t getHeight() const; // Projection void getWorldBoundsMeters(ProjectedMeters& sw, ProjectedMeters& ne) const; void getWorldBoundsLatLng(LatLng& sw, LatLng& ne) const; double getMetersPerPixelAtLatitude(double lat, double zoom) const; ProjectedMeters projectedMetersForLatLng(const LatLng&) const; LatLng latLngForProjectedMeters(const ProjectedMeters&) const; PrecisionPoint pixelForLatLng(const LatLng&) const; LatLng latLngForPixel(const PrecisionPoint&) const; // Annotations AnnotationID addPointAnnotation(const PointAnnotation&); AnnotationIDs addPointAnnotations(const std::vector&); AnnotationID addShapeAnnotation(const ShapeAnnotation&); AnnotationIDs addShapeAnnotations(const std::vector&); void removeAnnotation(AnnotationID); void removeAnnotations(const AnnotationIDs&); AnnotationIDs getPointAnnotationsInBounds(const LatLngBounds&); LatLngBounds getBoundsForAnnotations(const AnnotationIDs&); double getTopOffsetPixelsForAnnotationSymbol(const std::string&); // Sprites void setSprite(const std::string&, std::shared_ptr); void removeSprite(const std::string&); // Memory void setSourceTileCacheSize(size_t); void onLowMemory(); // Debug void setDebug(bool value); void toggleDebug(); bool getDebug() const; void setCollisionDebug(bool value); void toggleCollisionDebug(); bool getCollisionDebug() const; bool isFullyLoaded() const; void dumpDebugLogs() const; private: View& view; const std::unique_ptr transform; const std::unique_ptr data; const std::unique_ptr> context; enum class RenderState { never, partial, fully }; RenderState renderState = RenderState::never; }; } #endif