问题
Right now i have a dynamically generated google static map image with a path drawed in it. That path it´s composed by 'x' number of separated paths, and i want to set a different color for each one, but i can´t find a way to do that, (if it´s possible). I´m working in PHP.
Now i have something like this:
http://maps.google.com/maps/api/staticmap?center=' . $latitude . ',' . $longitude . '&zoom=15&format=jpg&size=640x640&scale=4&maptype=hybrid&markers=icon:http://myweburl/myownmarkerimage.png%7Clabel:C%7C' . $markerlat . ',' . $markerlong . '&path=color:0x0517bcDD| . $pathpoints
That code is working perfectly, but the path has one color. I want to change that color for each 'pathpoint'. I tried to declare multiple path tag on the URL, and multiple color selectors, but nothing worked.
Thank you all for your responses.
回答1:
You can add multiple paths to a static map. Each path has a single color:
http://maps.google.com/maps/api/staticmap?path=color:0x0000FF80|weight:5|37.401528,-122.11372|37.3955278,-122.1018791&path=color:0xFF000080|weight:5|37.3955278,-122.101879|37.38789,-122.0883&path=color:0x00FF0080|weight:5|37.38789,-122.08866|37.380388,-122.072697&size=500x300
example
Note however, there is a maximum length allowed for the URL.
You can also use encoded polylines to specify the path:
http://maps.google.com/maps/api/staticmap?path=color:0x0000FF80|weight:5|enc:_|gcFthihV|a@_iA&path=color:0xFF000080|weight:5|enc:ayfcFp|fhV`m@qpA&path=color:0x00FF0080|weight:5|enc:mzccFnkahVqo@n~A&size=500x300
example
来源:https://stackoverflow.com/questions/30509347/it%c2%b4s-a-way-to-set-multiple-color-paths-in-google-static-map