Unless that co-worker is part of your companies HR team who has the right to make sure you are keeping your hours... No, it's not legal. However, many companies insist you use apps they create for your phone, to stay in touch.
Many of these allow employers to track you, even during off hours. Technically, if they are caught checking on your non work hours... They can get in trouble. If this co-worker is not part of the management, they should not be tracking you... Tell your boss or tell the police, or both.