I am new to Google Maps, so I have most likely missed something very basic. I want to group several lines, way points, locations .. logically together, so that I can switch them on / off at once. I thought this is a layer or overlay, but I am still confused about the difference.
On Playground I found the traffic overlay example which is basically doing what I want to do. But what kind of overlay is right for me? And how will draw the line to a particular overlay?
A similar question Google Maps marker grouping is doing this by categories on the marker and more or less iterating through them to switch them on/off - is there no easier way?
I could, of course, keep all elements (lines, markers) of a group in an array and this array would represent my logical group. Is this the right way?
var path = waypointsToLatLngPath(myWaypoints); // generate path from waypoint
var line = new google.maps.Polyline({
path: path,
strokeColor: '#ff0000',
strokeOpacity: 1.0,
strokeWeight: 1
});
line.setMap(map);