#1 Fixed image proportions
parent
1c3b19962f
commit
f1d43876ef
22
script.js
22
script.js
|
@ -53,10 +53,30 @@ function updateStreetView(loc){
|
||||||
* (180/Math.PI) ) % 360;
|
* (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
|
// Get streetview data
|
||||||
getStreetViewData(loc, 2, function(data){
|
getStreetViewData(loc, 2, function(data){
|
||||||
console.log('https://maps.googleapis.com/maps/api/streetview?'+
|
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() +
|
'&location='+ data.location.latLng.lat() +','+ data.location.latLng.lng() +
|
||||||
'&fov=90' + // Inclination
|
'&fov=90' + // Inclination
|
||||||
// Show direction if moving, point to user if stationary
|
// Show direction if moving, point to user if stationary
|
||||||
|
|
Loading…
Reference in New Issue