%
% Callback function installed in processDist.m. It is attached to the
% subplots in the E/N/U graphs. Whenever the user zooms in/out this
% function gets called if installed. The x-axis is time so simply
% determine the axis limits using the axis command. The find the
% matching Lat/Long data for that time span and copy into the variable
% which is linked to the X/Y axis of a lat/long plot. Change the focus
% to that graph and refresh the data.
%
% Input:
%  obj       - Matlab passes this in 
%  event_obj - Matlab passes this in - I believe this is the object that
%              caused the callback, in our use the E/N/U graph
%  myplot    - figure handle to the google map figure we will change the 
%              position data in
%  index     - index to the data set we need to modify

function MapZoomCallback(obj,event_obj,myplot,index)
  global TimeLatLong;
  global TimeLatLongAll;

  A = axis;
  % Find the data range keeping the NaNs so that we can retain the pen-up/pen-down 
  % if there are gaps in the data
  i = find( ( (TimeLatLongAll{index}(:,1) >= A(1)) & (TimeLatLongAll{index}(:,1) <= A(2))) | isnan(TimeLatLongAll{index}(:,1)) );
  TimeLatLong{index} = TimeLatLongAll{index}(i,:);
  figure(myplot);
  refreshdata;
end

