Search code examples
google-mapsgoogle-maps-api-3encodepolylinegoogle-polyline

how to use separated encoded polylines in a map using google maps api v3


Anyone knows why, compared to version v2, in v3 of google maps api using, in a single map, multiple encoded polylines, i view them as an unique (joined) path?

as you can see here http://www.campiscout.com/index.php?option=com_wrapper&view=wrapper&Itemid=37 in v2 i'm able to push them perfectly separated.

my test website with v3 version is here: http://www.zupa.it/joomla25/hike-route-trekking

encoded paths are stored in a mysql db, and they are passed to maps via xml

is there a solution to my problem? is it a bug or i made some mistake or forgot somethings?

after some weeks pasted on the net searching for a solution, I will appreciate any help.

thanks in advance.

B.


Solution

  • You have 1 global variable tempPoly there and you extend the path of this polyline in addLocation with all locations of all markers.

    Use this to create the polyline inside the callback of downloadUrl():

    new google.maps.Polyline({
       strokeColor: '#FF3333',
       strokeOpacity: 1.0,
       strokeWeight: 2,
       path: decodedPath,
       map:map
    });
    

    ...and remove this from addLocation():

    tempPoly.setPath(latlngs);