diff --git a/script.js b/script.js index e6de9ab..6b990b8 100644 --- a/script.js +++ b/script.js @@ -53,10 +53,30 @@ function updateStreetView(loc){ * (180/Math.PI) ) % 360; } + // Get dimensions for sv request (images proportional to element up to 640x640) + function getDimensions(element) { + + // Window is smaller than max + if ( element.width()<640 && element.height()<640 ){ + return element.width()+'x'+element.height(); + } + + // Width must be made proportional to 640 + else if (element.width()>element.height()) { + return '640x'+element.height()*640/element.width(); + } + + // Height must be made proportional to 640 + else { + return element.width()*640/element.height()+'x640'; + } + + } + // Get streetview data getStreetViewData(loc, 2, function(data){ console.log('https://maps.googleapis.com/maps/api/streetview?'+ - 'size='+ $('main img').width() +'x'+ $('main img').height() + + 'size='+ getDimensions($(window)) + '&location='+ data.location.latLng.lat() +','+ data.location.latLng.lng() + '&fov=90' + // Inclination // Show direction if moving, point to user if stationary