如何加载带有路径(折线)的静态谷歌地图? [英] How to load a static google map with a path (polyline)?

查看:29
本文介绍了如何加载带有路径(折线)的静态谷歌地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一些代码,可以在单击列表视图项时从 URL 加载图像;这已经用虚拟"图像进行了测试,并且在图像视图对象中显示的图像没有任何问题.

I have implemented some code that loads an image from a URL upon a listview item being clicked; this has been tested with a 'dummy' image and works without any problem with the image being displayed in an imageview object.

然而,我真正想做的是通过 URL 加载带有路径(折线)的静态谷歌地图,但由于某种原因这不起作用,我希望这里的人能够告诉我有什么问题我的网址:

However, what I really want to do is to load a Static Google Map with Paths (polyline) via URL, but for some reason this is not working and I hope that someone here will be able to tell me what is wrong with my URL:

http://maps.googleapis.com/maps/api/staticmap?size=400x400&path=40.737102,-73.990318|40.749825,-73.987963|40.752946,-73.987384|40.755823,-73.986397

根据 Google 文档 http://code.google.com/apis/maps/documentation/staticmaps/ 我相信我的 URL 应该可以工作,因为带有路径的图像只需要 size 属性(即所有其他属性都是可选的).

According to the Google documentation http://code.google.com/apis/maps/documentation/staticmaps/ I believe that my URL should work, because an image witha path only requires the size attribute (i.e. all others are optional).

当我尝试通过网络浏览器测试加载我的 URL 时,我在 Google Chrome 中收到错误 403,告诉我 googleapis 网站需要登录.这是 API 密钥吗?我有一个以前用于非静态谷歌地图的 API 密钥,我将此密钥从地图的 xml 复制/粘贴到我的 URL 中(使用 key= 属性),但同样没有成功.

When I try to test load my URL via a web-browser I receive an Error 403 in Google Chrome telling me that the googleapis website requires a log in. Is this the API key? I have an API key that I've previously used for a non-static google map and I copy/pasted this key from the map's xml into my URL (using the key= attribute), but again this was not successful.

我试过在 google 和这个论坛上搜索,但似乎以前没有人遇到过这个问题 - 或者我可能真的不擅长搜索 :( 但希望有人能提供帮助?

I've tried searching on google and this forum, but it seems that no-one has had this problem before - or maybe I'm just really bad at searching :( But hopefully someone can assist?

谢谢!

推荐答案

您缺少所需的 sensor 参数.

http://maps.googleapis.com/maps/api/staticmap?size=400x400&path=40.737102,-73.990318|40.749825,-73.987963|40.752946,-73.987384|40.755823,-73.986397&sensor=false

这篇关于如何加载带有路径(折线)的静态谷歌地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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