Skip to content

Commit 53f9a65

Browse files
committed
Try to implement blueprint for Map
1 parent bdf4aa7 commit 53f9a65

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

crates/re_space_view_map/src/map_space_view.rs

+36-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
use egui::{Color32, TextEdit};
2-
3-
use re_types::components::{Color, Radius};
4-
5-
use walkers::{Map, MapMemory, Plugin, Tiles, TilesManager};
61
use {
7-
egui::{self, Context},
2+
egui::{self, Color32, Context, TextEdit},
83
re_entity_db::EntityProperties,
94
re_log_types::EntityPath,
105
re_space_view::suggest_space_view_for_each_entity,
116
re_types::blueprint::components::MapProvider,
12-
re_types::{SpaceViewClassIdentifier, View},
7+
re_types::{
8+
components::{Color, Radius},
9+
SpaceViewClassIdentifier, View,
10+
},
11+
re_ui::UiExt,
1312
re_viewer_context::{
1413
SpaceViewClass, SpaceViewClassLayoutPriority, SpaceViewClassRegistryError, SpaceViewId,
1514
SpaceViewSpawnHeuristics, SpaceViewState, SpaceViewStateExt as _,
1615
SpaceViewSystemExecutionError, SpaceViewSystemRegistrator, SystemExecutionOutput,
1716
ViewQuery, ViewerContext,
1817
},
18+
walkers::{Map, MapMemory, Plugin, Tiles, TilesManager},
1919
};
2020

2121
use crate::map_visualizer_system::{MapEntry, MapVisualizerSystem};
@@ -153,7 +153,17 @@ impl SpaceViewClass for MapSpaceView {
153153
let map_state = state.downcast_mut::<MapSpaceViewState>()?;
154154
let mut selected = map_state.selected_provider;
155155

156-
// TODO(tfoldi): UI looks horrible, needs to be improved
156+
// TODO(tfoldi): seems there is no implementation for combo box in view_property_ui
157+
// list_item::list_item_scope(ui, "map_selection_ui", |ui| {
158+
// view_property_ui::<re_types::blueprint::archetypes::MapOptions>(
159+
// ctx,
160+
// ui,
161+
// space_view_id,
162+
// self,
163+
// state,
164+
// );
165+
// });
166+
157167
ui.horizontal(|ui| {
158168
ui.label("Map provider");
159169
egui::ComboBox::from_id_source("map_provider")
@@ -176,6 +186,12 @@ impl SpaceViewClass for MapSpaceView {
176186
"Mapbox Satellite",
177187
);
178188
});
189+
190+
// If the selected provider has changed, reset the tiles.
191+
if selected != map_state.selected_provider {
192+
map_state.tiles = None;
193+
map_state.selected_provider = selected;
194+
}
179195
});
180196

181197
ui.horizontal(|ui| {
@@ -186,21 +202,21 @@ impl SpaceViewClass for MapSpaceView {
186202
});
187203

188204
ui.horizontal(|ui| {
205+
let mut is_following = map_state.map_memory.detached().is_none();
206+
189207
if ui
190-
.button("Follow position")
191-
.on_hover_text("Follow the position of the entity on the map.")
192-
.clicked()
208+
.re_checkbox(&mut is_following, "Follow positions on map")
209+
.changed()
193210
{
194-
map_state.map_memory.follow_my_position();
211+
if is_following {
212+
map_state.map_memory.follow_my_position();
213+
} else {
214+
// Detach the map from the current position
215+
// TODO(tfoldi): should be added to the map_memory API
216+
}
195217
}
196218
});
197219

198-
// If the selected provider has changed, reset the tiles.
199-
if selected != map_state.selected_provider {
200-
map_state.tiles = None;
201-
map_state.selected_provider = selected;
202-
}
203-
204220
Ok(())
205221
}
206222

@@ -275,3 +291,5 @@ fn get_tile_manager(provider: MapProvider, mapbox_access_token: &str, egui_ctx:
275291
),
276292
}
277293
}
294+
295+
re_viewer_context::impl_component_fallback_provider!(MapSpaceView => []);

0 commit comments

Comments
 (0)