#1 Fixed image proportions

master
Keith Irwin 2017-09-25 23:40:29 +00:00
parent 1c3b19962f
commit f1d43876ef
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
1 changed files with 21 additions and 1 deletions

View File

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