1
- use egui:: { Color32 , TextEdit } ;
2
-
3
- use re_types:: components:: { Color , Radius } ;
4
-
5
- use walkers:: { Map , MapMemory , Plugin , Tiles , TilesManager } ;
6
1
use {
7
- egui:: { self , Context } ,
2
+ egui:: { self , Color32 , Context , TextEdit } ,
8
3
re_entity_db:: EntityProperties ,
9
4
re_log_types:: EntityPath ,
10
5
re_space_view:: suggest_space_view_for_each_entity,
11
6
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 ,
13
12
re_viewer_context:: {
14
13
SpaceViewClass , SpaceViewClassLayoutPriority , SpaceViewClassRegistryError , SpaceViewId ,
15
14
SpaceViewSpawnHeuristics , SpaceViewState , SpaceViewStateExt as _,
16
15
SpaceViewSystemExecutionError , SpaceViewSystemRegistrator , SystemExecutionOutput ,
17
16
ViewQuery , ViewerContext ,
18
17
} ,
18
+ walkers:: { Map , MapMemory , Plugin , Tiles , TilesManager } ,
19
19
} ;
20
20
21
21
use crate :: map_visualizer_system:: { MapEntry , MapVisualizerSystem } ;
@@ -153,7 +153,17 @@ impl SpaceViewClass for MapSpaceView {
153
153
let map_state = state. downcast_mut :: < MapSpaceViewState > ( ) ?;
154
154
let mut selected = map_state. selected_provider ;
155
155
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
+
157
167
ui. horizontal ( |ui| {
158
168
ui. label ( "Map provider" ) ;
159
169
egui:: ComboBox :: from_id_source ( "map_provider" )
@@ -176,6 +186,12 @@ impl SpaceViewClass for MapSpaceView {
176
186
"Mapbox Satellite" ,
177
187
) ;
178
188
} ) ;
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
+ }
179
195
} ) ;
180
196
181
197
ui. horizontal ( |ui| {
@@ -186,21 +202,21 @@ impl SpaceViewClass for MapSpaceView {
186
202
} ) ;
187
203
188
204
ui. horizontal ( |ui| {
205
+ let mut is_following = map_state. map_memory . detached ( ) . is_none ( ) ;
206
+
189
207
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 ( )
193
210
{
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
+ }
195
217
}
196
218
} ) ;
197
219
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
-
204
220
Ok ( ( ) )
205
221
}
206
222
@@ -275,3 +291,5 @@ fn get_tile_manager(provider: MapProvider, mapbox_access_token: &str, egui_ctx:
275
291
) ,
276
292
}
277
293
}
294
+
295
+ re_viewer_context:: impl_component_fallback_provider!( MapSpaceView => [ ] ) ;
0 commit comments