Added logic for moving objects

master
Keith Irwin 2017-08-07 10:38:59 -04:00
parent 3d3838943b
commit 7a40e7a6d1
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
1 changed files with 4 additions and 3 deletions

View File

@ -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);