Maria globe client/Auto follow
Jump to navigation
Jump to search
In this section, we will utilise the globe control auto follow functionality.
- 2D
-
- valid for tracks and all draw object types
- the specified object will always be displayed with its center point in the center of the screen.
- if the item position is changed, the map area will be adjusted accordingly.
- 3D
-
- valid for tracks and point objects only
Auto follow control and display
Add the following GUI elements to your main window:
- Check box to enable/disable auto follow
- Text box for display of currently followed item
The XAML could look something like this:
...
<GroupBox Header="Auto follow">
<StackPanel>
<CheckBox Margin="3"
Content="Follow selected"
IsChecked="{Binding IsAutoFollowActive}" />
<Label Content="Currently followed:" FontWeight="DemiBold" />
<TextBox Margin="3"
Text="{Binding AutoFollowItemName, Mode=OneWay}"
IsReadOnly="True"/>
</StackPanel>
</GroupBox>
...
In MainViewModel implement:
- Auto follow property,
- auto update property with timer, initialised in during the LayerInitialized event handler.
...
public bool IsAutoFollowActive
{
get
{
return GlobeMapViewModel.AutoFollow.TargetItem != null;
}
set
{
if (!(value && GlobeMapViewModel.AutoFollow.FollowSelectedItem()))
GlobeMapViewModel.AutoFollow.TargetItem = null;
NotifyPropertyChanged(() => IsAutoFollowActive);
NotifyPropertyChanged(() => AutoFollowItemName);
}
}
public string AutoFollowItemName
{
get
{
if (GlobeMapViewModel?.AutoFollow?.TargetItem != null)
{
return GlobeMapViewModel.AutoFollow.TargetItem.ToString();
}
return "Inactive";
}
}
...
Running with auto follow
Activating/deactivating auto follow functionality, observe the following:
- in 3D mode, tracks and point objects only can be selected.
- the map will re-position to the activated item if the map is panned.
- the map will re-position to the activated item if the item is moved.
- the activated item will stay activated also when deselected in the map and when another item is selected.
- To activate another item - deactivate, then activate the new item.
No auto follow, 2D | |
Auto follow volume object, 2D |
Auto follow line object, 2D |
Auto follow point object, 2D |
Auto follow track, 2D |
Auto follow point object, 3D |
Auto follow track, 3D |