Google街景地图-解析网址以用作街道图像 [英] Google Street View Maps - Parsing url to use as street image
问题描述
情况:我正在为客户开发地图功能,我需要能够获取街景的屏幕截图,然后将其显示为轮播(类似于Google本身的方式).他们可以在CMS中选择所需的位置.
我能想到的唯一方法(考虑到非技术最终用户)是允许他们复制并粘贴街景中的URL,然后将其解析出来.
例如:
60.959789(lat)-149.112111(长)3a(未知)75y(视野)104.14h(标题)94.39t(螺距)/data =!3m4!1e1!3m2!1sJmW2DmZWQ2bIcAcHlky4-w!2e0(未知)
但是,当我将它们插入图像的url结构中时,我得到:
.
.我尝试避免回答自己的问题,但这是我从Google Street视图解析URL以便在其Street View Image API中使用的发现.>
60.959789(lat)-149.112111(长)3a(未知)75y(视野)104.14h(标题)94.39t(螺距)/data =!3m4!1e1!3m2!1sJmW2DmZWQ2bIcAcHlky4-w!2e0(未知)
data
属性是一个有趣的属性.这篇博客文章帮助我弄清楚了.
该属性的每个段均以!",一个1-5(或更可能是数字)和一个字母(m,e等)开头.
由于某些原因,第四个元素(从0开始计数时为第三个元素)是 pano
属性.
我不确定其他属性与什么有关,但我想知道.
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.
will give you:
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:
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.
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:
I'm not sure what the other attributes pertain to, but I'd like to know.
这篇关于Google街景地图-解析网址以用作街道图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!