Google街景地图-解析网址以用作街道图像 [英] Google Street View Maps - Parsing url to use as street image

查看:54
本文介绍了Google街景地图-解析网址以用作街道图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:我正在为客户开发地图功能,我需要能够获取街景的屏幕截图,然后将其显示为轮播(类似于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 属性.

因此,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:

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

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:

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

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

这篇关于Google街景地图-解析网址以用作街道图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆