Location Tracker
About this app
Track user location and visualize it on a map
Location Tracker Location Tracker
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Location Tracker</title>
<meta name="description" content="Track user location and visualize it on a map">
<meta name="keywords" content="location, tracking, map">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
document.addEventListener("DOMContentLoaded", function() {
// Array to store location data
var locations = [];
// Function to add a new location to the array
function addLocation(id, latitude, longitude, time) {
locations.push({
id: id,
latitude: latitude,
longitude: longitude,
time: time
});
}
// Function to render the map with markers
function renderMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: {lat: 0, lng: 0}
});
for (var i = 0; i < locations.length; i++) {
var location = locations[i];
var marker = new google.maps.Marker({
position: {lat: location.latitude, lng: location.longitude},
map: map,
title: 'User ' + location.id
});
}
}
// Add sample locations
addLocation(1, 37.7749, -122.4194, '2022-07-01 12:00:00');
addLocation(2, 34.0522, -118.2437, '2022-07-01 12:30:00');
addLocation(3, 40.7128, -74.0060, '2022-07-01 13:00:00');
// Render the map
renderMap();
});
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
<style>
/* App CSS Goes Here */
#map {
height: 400px;
width: 100%;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Location Tracker</h1>
<div id="map"></div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
</body>
</html>
NEW APPS
These are apps made by the community!