2011-02-22 136 views
5

我试图生成一个静态谷歌地图上的一些点,并连接这些点的一些线(我很快会让行与驾驶方向,但后来)。这样现在我已经得到了代码生成的网址:谷歌静态地图API:生成具有路径的静态地图

def getStaticMapAddress(self, route): 
    url = "http://maps.google.com/maps/api/staticmap?center="+str(route[0].location.lat)+","+str(route[0].location.lng)+"&zoom=6&size=400x400&markers=" 
    i=0 
    while i<len(route): 
     url += str(route[i].location.lat)+","+str(route[i].location.lng) 
     i=i+1 
     if (i < len(route)): 
      url += "|" 
    url += "&path=color:0xff0000ff&weight:5" 
    i=0 
    while i<len(route): 
     url += "|"+str(route[i].location.lat)+","+str(route[i].location.lng) 
     i+=1 
    url += "&sensor=false" 
    return url 

在这个功能中,“路径”是与相关位置的用户列表。随着我的测试数据,生成该网址:

http://maps.google.com/maps/api/staticmap?center=50.8202008,-0.1324898&zoom=6&size=400x400&markers=50.8202008,-0.1324898|51.447341,-0.0761212|51.4608947,-2.5884312&path=color:0xff0000ff&weight:5|50.8202008,-0.1324898|51.447341,-0.0761212|51.4608947,-2.5884312&sensor=false 

如果你看一下静态地图,你可以看到标志,但不是路径。我一直在寻找这个文档(http://code.google.com/apis/maps/documentation/staticmaps/#Paths),我看不到我出错的地方。看看这些示例,我的URL似乎与示例具有完全相同的格式。有谁知道我做错了什么?

感谢

回答