6#include "map_feature_hover.hpp"
7#include <mbgl/map/map.hpp>
8#include <mbgl/util/run_loop.hpp>
9#include <mbgl/util/timer.hpp>
21namespace mbgl {
namespace gfx {
class RendererBackend; } }
23struct CachedPoiResult {
28 std::string sourceClass;
29 std::string sourceSubclass;
30 double latitude = 0.0;
31 double longitude = 0.0;
34struct InteractivePoiMarker {
35 std::size_t index = 0;
42 bool contains(
double x,
double y)
const {
43 return x >= left && x <= right && y >= top && y <= bottom;
47struct PoiSearchResult {
55class MapView :
public mbgl::MapObserver {
57 using ManualCameraCallback = std::function<void()>;
58 using MapClickCallback = std::function<void(
59 double,
double,
double,
const std::string&, std::size_t)>;
61 using PoiSelectedCallback = std::function<void(
62 const std::string& name,
63 const std::string& brand,
64 const std::string& sourceClass,
65 const std::string& sourceSubclass,
69 MapView(
const mbgl::ResourceOptions& resourceOptions,
const mbgl::ClientOptions& clientOptions);
71 float getPixelRatio()
const;
72 mbgl::Size getSize()
const;
73 mbgl::gfx::RendererBackend& getRendererBackend();
74 void setMap(mbgl::Map* map);
79 void finishCameraGesture();
80 void setShouldClose();
81 void onWillStartRenderingFrame()
override;
84 void onDidFailLoadingMap(mbgl::MapLoadError error,
const std::string& message)
override;
88 mbgl::TileOperation operation,
89 const mbgl::OverscaledTileID& tileId,
90 const std::string& sourceId
97 void setUpdateCallback(std::function<
void()> callback);
98 void setPoiSelectedCallback(PoiSelectedCallback callback);
99 void setManualCameraCallback(ManualCameraCallback callback);
100 void setMapClickCallback(MapClickCallback callback);
101 void setPoiResultsJson(
const std::string& geojson);
102 void setCityWeatherJson(
const std::string& geojson);
104 std::string searchWeatherCities()
const;
105 PoiSearchResult searchVisiblePois(
const std::string& category)
const;
108 static void onWindowResize(GLFWwindow* window,
int width,
int height);
109 static void onFramebufferResize(GLFWwindow* window,
int width,
int height);
110 static void onScroll(GLFWwindow* window,
double xOffset,
double yOffset);
111 static void onWindowFocus(GLFWwindow* window,
int focused);
112 static void onMouseClick(GLFWwindow* window,
int button,
int action,
int modifiers);
113 static void onMouseMove(GLFWwindow* window,
double x,
double y);
114 static void onCursorEnter(GLFWwindow* window,
int entered);
115 void updateMapHover();
116 void publishCityWeatherHover();
117 void publishPoiHover();
118 void clearMapHover();
119 std::vector<InteractivePoiMarker> interactivePoiMarkers()
const;
122 mbgl::Map* map =
nullptr;
124 std::unique_ptr<GLFWBackend> backend;
125 GLFWwindow* window =
nullptr;
128 float pixelRatio = 1.0f;
133 double lastClick = -1.0;
134 bool tracking =
false;
135 bool manualGesturePublished =
false;
137 mbgl::util::RunLoop runLoop;
138 mbgl::util::Timer frameTick;
139 std::function<void()> updateCallback;
140 PoiSelectedCallback poiSelectedCallback;
141 ManualCameraCallback manualCameraCallback;
142 MapClickCallback mapClickCallback;
143 std::vector<CachedPoiResult> poiResults;
144 MapFeatureHover cityWeatherHover;
145 MapFeatureHover poiHover{
"id",
"",
"poi_hover"};
146 bool pointerInside =
false;
147 double lastHoverCheck = -1.0;
Connects MapLibre rendering updates to a MapView window.
Definition map_renderer_frontend.hpp:29