如何使用方向创建静态api地图

时间:2014-04-17 15:11:01

标签: google-api google-static-maps

我正在尝试构建一个静态谷歌地图,其中包含从villanova,pa到devon,pa的路线。我也生成了一个谷歌API密钥,我无法建立网址。 你可以给我一个样本网址,这样我就可以看到它是如何形成新的。

感谢

1 个答案:

答案 0 :(得分:9)

看这里:Google Maps API Doc

基本上流程是: 1)您询问方向(通过Directions API) 2)在XML / JSon结果中,您将找到如下标记:

 <overview_polyline>
   <points> a lot of chars here.. </points>
 </overview_polyline>

3)你要求在网址中指定静态地图:

path=enc:<the lot of chars you got in (2) >

这是一张示例图片:

THIS

这个URL请求: https://maps.googleapis.com/maps/api/staticmap?size=400x400&path=enc:sizwFsq_z@Lg@j@o@bASbBLpCt@n@%5El@x@%5CN~Cd@nHCn@EdDdDv@n@lG%7CAgBhFUrADn@Zx@hMfStF%7CIvBrDl@dEJxBMlEG%60CVjBv@lEPjBIbAM%60@GAMDKNBh@JLBLa@lD@zD%60@rCzApFxBvJtEfVZdEq@fBaAZi@Ik@_@%7DBsB%7DBuA%7BAa@_Gw@oDNwBf@wEjCo@n@gErE%7DLdNqIfKeBpCoApCy@dCwArFgC%60RaD%7COmAnE%7BDpIcDvFeDdEmDxDkD%60CwG~Dyg@tUwJzFy@p@kExEcLrPiDrCaDbBwFlC_F%60EuAlBiB%7CDiA%60Eg@tCm@pHErFbApPFpDGpA_@~Dc@vBwAhEyDzIeBzDsBvC_A~@eC%60B_C%7C@aDd@%7DHGsKAsGDsDXsDv@uEjBiCbBmE~DaDzDqG%60IyFnGqFdFoHvEqHtC_PnEeF~AoFxBgGxDkFtE%7DGnJqCxF%7DAbEcBnGyAxGsBjKoGn%5CoBtIwCrJyApD_EnIyGzKmNlTyJzNsClDiF~EkI%7CFuAx@wIlFwJ%7CFiH%60FwGdFgJbI%7BNbNmGdGqH%60IiEpFaExGqDnHoBfFyCtJwBxIoJ%60d@iHhWqIpU%7BPzc@aCtF%7DFlJcHdHwF%7CDgH%7CCqWxGqElByDxBsFh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