Google Street View Maps - Parsing url to use as street image

泪湿孤枕 提交于 2021-02-08 04:11:07

问题


Situation: I'm working on a map feature for a client and I need the ability to get screenshots of a street view, and then display them as a carousel (similar to how Google does it natively). They can choose whatever locations they want in their CMS.

The only way I can think of to do this (taking into account non-tech end users) is to allow them to copy and paste the URL from a street view, and then parse it out.

For example: https://www.google.com/maps/@60.959789,-149.112111,3a,75y,104.14h,94.39t/data=!3m4!1e1!3m2!1sJmW2DmZWQ2bIcAcHlky4-w!2e0

will give you: enter image description here

After tinkering around, I figure the following breakdown corresponds to paramerters for the Google Street View Image API

60.959789 (lat)
-149.112111 (long)
3a (unknown)
75y (field of view)
104.14h (heading)
94.39t (pitch)
/data=!3m4!1e1!3m2!1sJmW2DmZWQ2bIcAcHlky4-w!2e0 (unknown)

However, when I plug these into the url structure for an image, I get:

https://maps.googleapis.com/maps/api/streetview?size=400x400&location=60.959789,-149.112111&fov=75&heading=104.14&pitch=94.39

enter image description here

Question

What am I screwing up?

Can I do this a better way?

Addendum: In addition, how can I get the right pano attribute from relevant photosphere shots? For example, how can I get a Street View Image of this photosphere.


回答1:


I try to avoid answering my own questions, but heres what I found about parsing a URL from Google Street view for use in their Street View Image API.

60.959789 (lat)
-149.112111 (long)
3a (unknown)
75y (field of view)
104.14h (heading)
94.39t (pitch)
/data=!3m4!1e1!3m2!1sJmW2DmZWQ2bIcAcHlky4-w!2e0 (unknown)

The data attribute is the interesting one. This blog article helped me figure it out.

Each segment of the attribute is preceded by "!", a number from 1 - 5 (or more presumably), and a letter (m, e, etc).

For some reason the fourth element (3rd, when counting from 0) is the pano attribute.

Therefore, this street view of the Acropolis can be parsed into this url for an image:

https://maps.googleapis.com/maps/api/streetview?size=200x200&location=37.971822,23.726532&fov=75&heading=163.13&pitch=7.599999999999994&pano=fPhZjlaq_sAAAAQYNw-Ypw

enter image description here

I'm not sure what the other attributes pertain to, but I'd like to know.



来源:https://stackoverflow.com/questions/28489214/google-street-view-maps-parsing-url-to-use-as-street-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!