%% Plot the Movement of Two Vehicles
% Load data for the route.

data = load('geoRoute.mat');

% Extract data for the first vehicle.

lat1 = data.latitude;
lon1 = data.longitude;

% Create a synthetic route for second vehicle that drives the same route in the opposite direction.

lat2 = flipud(lat1);
lon2 = flipud(lon1);

% Initialize the player to view the last 10 positions.

zoomLevel = 12;
player = geoplayer(lat1(1), lon1(1), zoomLevel, 'HistoryDepth',...
    10, 'HistoryStyle', 'line');

%  Plot positions of both vehicles.

loopCounter = length(lat1);
for i = 1:loopCounter
     plotPosition(player, lat1(i), lon1(i), 'TrackID', 1, 'Label', 'Vehicle 1');
     plotPosition(player, lat2(i), lon2(i), 'TrackID', 2, 'Label', 'Vehicle 2');
end

% Copyright 2019 The MathWorks, Inc.