Relisora Relisora -3 years ago 37
Javascript Question

How to get the serveur address where google interior view images are stocked?

I am using the Google maps API v3 to create a portfolio.

Question :


Is there a way to generate the default image link, that would work on every google server, or a way to know what server is used so I can generate the link accordingly ?





Here is an example of what I'm currently doing. It may or may not help you finding an answer

User path :


  • The user enters the address of his business.

  • An iframe is displayed with the interior view of this business

  • The user can navigate on this iframe to select his default picture



From the view selected with the iframe, I can create an image URL directly from the Google servers that I set as default image.

At the moment, this URL can be (JS):

var image = "https://geo3.ggpht.com/cbk?panoid=" + panoId + "&output=thumbnail&cb_client=search.LOCAL_UNIVERSAL.gps&thumb=2&w=689&h=487&yaw=" + povHeading + "&pitch=" + povPitch + "&thumbfov=" + fov;


or

var image = "https://lh5.googleusercontent.com/" + panoId + "/w689-h487-k-no-pi"+povPitch+"-ya"+povHeading+"-ro0-fo"+fov+"/";


This worked for a vast majority of the cases, but as more people are using the service, some special cases appeared (example link) :

https://lh3.ggpht.com/-1dwRgcXpyYk/WS7bUYtLEdI/AAAAAAAAObA/zd-aK-rfWxYvA302eg6WT7qQoEKRrUxGgCLIB/x2-y2-z3/p

I am saving the link for the both first cases but I have not found a general rule that can be applied.
The user that entered his business having this 3rd example link is getting a 404 img not found atm.

Here is the code I'm currently using, if it can help understanding the question (JS):



function generateImg() {

/* here I get all the vars used to create the image */

//generate img link
var image = "https://geo3.ggpht.com/cbk?panoid=" + panoId + "&output=thumbnail&cb_client=search.LOCAL_UNIVERSAL.gps&thumb=2&w=689&h=487&yaw=" + povHeading + "&pitch=" + povPitch + "&thumbfov=" + fov;

//if img does not exist
UrlExists(image, function(status){
if(status === 404){
// 404 not found
var image = "https://lh5.googleusercontent.com/" + panoId + "/w689-h487-k-no-pi"+povPitch+"-ya"+povHeading+"-ro0-fo"+fov+"/";
}
});
}




Answer Source

You can get consistent result with the official Api

var image = "https://maps.googleapis.com/maps/api/streetview?size=400x400&pano=" + panoId + "&fov=90&heading=235&pitch=10&key=" + API_KEY;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download