I recently started using Leaflet JS to create a dynamic map viewer that can monitor the movement of multiple devices. JSON data is being used to assign latitude and longitude coordinates to each marker.
The structure of the JSON data is as follows:
var Point = [
{
"id": 1,
"name": "A",
"LastUpdate": [36.8474448, 10.2793222],
"position": [36.8479648, 10.2793332]
},{
"id": 2,
"name": "B",
"LastUpdate": [36.8791079, 10.2656109],
"position":[ 36.8791039, 10.2656209]
},{
"id": 3,
"name": "C",
"LastUpdate": [36.9922641, 10.1255150],
"position": [36.9922751, 10.1255164]
}
];
This data includes position details for 3 devices (initially static). While I have been able to locate my device on the map, I am now looking to generate a list of its previous positions on the map. Below is the JavaScript code snippet I have used to locate my device:
var map = L.map('map').setView([36.8479648, 10.2793332], 10);map.locate({setView: true, maxZoom: 10,watch: true});