Auto Follow: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
The following example enables autofollow on different types of objects depending on what objects exists and are selected:
The following example enables autofollow on different types of objects depending on what objects exists and are selected:


<source>
<source lang="C#">


          string videoName = "Video";
  string videoName = "Video";
          var video = _videoLayerViewModel.Videos.FirstOrDefault(metadata => metadata.Name == videoName);
  var video = _videoLayerViewModel.Videos.FirstOrDefault(metadata => metadata.Name == videoName);
          if (video != null)
  if (video != null)
          {
  {
              _autoFollow.TargetItem = new VideoMetadataAutoFollowSource { Video = video };
      _autoFollow.TargetItem = new VideoMetadataAutoFollowSource { Video = video };
          }
  }


          else if (_trackLayer.Selected.Count() > 0)
  else if (_trackLayer.Selected.Count() > 0)
          {
  {
              _autoFollow.TargetItem = new TrackAutoFollowSource { ItemId = _trackLayer.Selected.First() };
      _autoFollow.TargetItem = new TrackAutoFollowSource { ItemId = _trackLayer.Selected.First() };
          }
  }


          else if (_drawObjectLayer.SelectedDrawObjectIds.Count() > 0)
  else if (_drawObjectLayer.SelectedDrawObjectIds.Count() > 0)
          {
  {
              _autoFollow.TargetItem = new DrawObjectAutoFollowSource { ItemId = _drawObjectLayer.SelectedDrawObjectIds.First() };
      _autoFollow.TargetItem = new DrawObjectAutoFollowSource { ItemId = _drawObjectLayer.SelectedDrawObjectIds.First() };
          }
  }


</source>
</source>

Revision as of 14:58, 13 August 2024

You can set up an Auto-Follow camera to track a moving entity in the map. The auto-follow source can be either a Track, Draw object or a VideoMetadata source.

The API documentation can be found here

Each target item type has a corresponding AutoFollowSource, i.e TrackAutoFollowSource, DrawObjectAutoFollowSource and VideoMetadataAutoFollowSource. These are initialized with either an ItemId or a VideoMetadata object.

Example

The following example enables autofollow on different types of objects depending on what objects exists and are selected:

   string videoName = "Video";
   var video = _videoLayerViewModel.Videos.FirstOrDefault(metadata => metadata.Name == videoName);
   if (video != null)
   {
      _autoFollow.TargetItem = new VideoMetadataAutoFollowSource { Video = video };
   }

   else if (_trackLayer.Selected.Count() > 0)
   {
      _autoFollow.TargetItem = new TrackAutoFollowSource { ItemId = _trackLayer.Selected.First() };
   }

   else if (_drawObjectLayer.SelectedDrawObjectIds.Count() > 0)
   {
      _autoFollow.TargetItem = new DrawObjectAutoFollowSource { ItemId = _drawObjectLayer.SelectedDrawObjectIds.First() };
   }