From 7a40e7a6d1e42195c1efd54a258e6b9a61ac3a3c Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Mon, 7 Aug 2017 10:38:59 -0400 Subject: [PATCH] Added logic for moving objects --- script.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index 60b802a..16d1f0f 100644 --- a/script.js +++ b/script.js @@ -52,11 +52,10 @@ function updateStreetView(loc){ // Set panorama getStreetViewData(loc, 2, function(data){ - pano.setPano(data.location.pano); + pano.setPano(data.location.pano); pano.setPov({ pitch: 0, - // Point towards users's location from street - heading: Math.atan((loc.lon-data.location.latLng.lng())/(loc.lat-data.location.latLng.lat()))*(180/Math.PI) + heading: (loc.spd>1)?loc.dir:Math.atan((loc.lon-data.location.latLng.lng())/(loc.lat-data.location.latLng.lat()))*(180/Math.PI) }); }); @@ -73,6 +72,8 @@ else { navigator.geolocation.watchPosition( newLoc = { lat: pos.coords.latitude, lon: pos.coords.longitude, + spd: pos.coords.speed, + dir: pos.coords.heading, tim: new Date() }; updateStreetView(newLoc,10);