Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (68 sloc) 3.12 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Realtime Tracking(Log Monitoring)</title>
<style>html,body{height:100%;}body{padding:0;margin:0;}h1{padding:0;margin:0;font-size:50%;}</style>
</head>
<body>
<!-- MAP[START] -->
<h1>Realtime Tracking(Log Monitoring)</h1>
<div id="myMap" style='width:60%;height:70%;float:left;'></div>
<button id="start_tracking">Start Tracking</button>
<button id="stop_tracking">Stop Tracking</button>
<button id="clear_map">Map Clear</button>
<!-- MAP[END] -->
<script src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[ *** YOUR MY KEY *** ]' async defer></script>
<script src="../js/BmapQuery.js"></script>
<script>
//****************************************************************************************
// BingMaps&BmapQuery
//****************************************************************************************
//Init
function GetMap(){
//------------------------------------------------------------------------
//1. Instance
//------------------------------------------------------------------------
const map = new Bmap("#myMap");
//------------------------------------------------------------------------
//2. Display Map
// startMap(lat, lon, "MapType", Zoom[1~20]);
// MapType:[load, aerial,canvasDark,canvasLight,birdseye,grayscale,streetside]
//------------------------------------------------------------------------
map.startMap(47.6149, -122.1941, "load", 17);
//------------------------------------------------------------------------
//3. Tracking Event(log monitoring)
//------------------------------------------------------------------------
//Start
let timer_id; //Timer:SetInterval_id
document.getElementById("start_tracking").onclick=function(){
//Tracking Start.
map.startTracking(false); //console.log => true or false
//:::Don't have to use (Check log):::
let timer = 5000; //Timer:5seconds
timer_id = setInterval(function(){
const len = map.getTrackingData().length-1; //Length:Tracking Log Data.
const val = map.getTrackingData(); //Value: Tracking Log Data.
const s = map.getTrackingTime().length-1; //Length:Tracking Log Data.
const sp = map.getTrackingTime(); //Value: TrackingTime Log Data.
console.log("New TrackData:", val[len] ); //Get New TrackingTime data[Array].
console.log("New TrackingTime:"+sp[s] ); //Get New tracking data[String].
},timer);
};
//Stop
document.getElementById("stop_tracking").onclick=function(){
map.stopTracking(); //Map: Tracking Log Stop.
console.log(map.getTrackingData()); //Log: Get Tracking Log All Data.
console.log(map.getTrackingTime()); //Log: Get TrackingTime Log All Data.
clearInterval(timer_id);
};
//Clear Map.
document.getElementById("clear_map").onclick=function(){
map.clearMap(); //Map: Clear Map.
map.clearTrackingData(); //Log: Clear Tracking Log All Data.
};
}
</script>
</body>
</html>
You can’t perform that action at this time.