Search code examples
google-mapsgoogle-maps-api-3google-maps-static-api

Combining Polylines on Google Static Map


I'm trying to make a static map request with multiple polylines. It works fine when I have a single polyline, but when I add them together I don't get the intended results. Specifically, I'm trying to highlight adjacent street blocks.

Polyline 1 works fine:

https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=400x400&path=weight:10%7Cenc:{d`pEnpypUc@_@u@Q

Polyline 2 works fine:

https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=400x400&path=weight:10%7Cenc:c``pEtjypUi@fAu@zA[j@mAzB

But combined, I get this:

https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=400x400&path=weight:10%7Cenc:{d`pEnpypUc@_@u@Q%7Cc``pEtjypUi@fAu@zA[j@mAzB

Solution

  • This works for me (separate the polyline specifications):

    https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=400x400&path=weight:10%7Cenc:c``pEtjypUi@fAu@zA[j@mAzB&path=weight:10%7Cenc:{d`pEnpypUc@_@u@Q
    

    (You need to add "&path=weight:10%7Cenc:YourEncodedPolylineHere" for each polyline)