Google Static Maps API: การสร้างแผนที่แบบคงที่พร้อมเส้นทาง

ฉันกำลังพยายามสร้างแผนที่ Google แบบคงที่โดยมีจุดบางจุดอยู่ และมีเส้นบางเส้นที่เชื่อมต่อจุดเหล่านี้ (เร็วๆ นี้ฉันจะทำให้เส้นเหล่านั้นสอดคล้องกับเส้นทางการขับขี่ แต่จะมาทีหลัง) ตอนนี้ฉันมีรหัสเช่นนี้เพื่อสร้าง URL:

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

ในฟังก์ชันนี้ 'เส้นทาง' คือรายชื่อผู้ใช้ที่มีตำแหน่งที่เกี่ยวข้องกัน ด้วยข้อมูลการทดสอบของฉัน 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 ของฉันดูเหมือนว่าจะมีรูปแบบเดียวกันกับตัวอย่างทุกประการ ไม่มีใครรู้ว่าฉันทำอะไรผิด?

ขอบคุณ

เบน


person benwad    schedule 22.02.2011    source แหล่งที่มา


คำตอบ (1)


มีบางอย่างผิดปกติกับพารามิเตอร์สีของเส้นทาง URI ต่อไปนี้ใช้งานได้สำหรับฉัน:

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=weight:5|50.8202008,-0.1324898|51.447341,-0.0761212|51.4608947,-2.5884312&sensor=false

และฉันเห็นเส้นสีน้ำเงินเริ่มต้น

อัปเดต: "มีบางอย่างผิดปกติ" คือตัวคั่นระหว่างสีเส้นทางและน้ำหนักเส้นทางคือ สัญลักษณ์ไปป์ ไม่ใช่เครื่องหมายและ นี้:

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

ทำงานและให้เส้นสีแดง

person Andrew Walker    schedule 01.03.2011