Reputation: 51
i have an array o markers and i want to create polylines according their title markers[i].title
. My brain can't think of a decent peace of code right now, so little help would be useful...
Upvotes: 0
Views: 1295
Reputation: 9292
You want likely a polyline based on the coordinates (LatLng) of the markers. Here is a template code:
function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(42.0, 10.0),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var points = [
new google.maps.LatLng(39.0, -3.0),
new google.maps.LatLng(52.1, 12.1),
new google.maps.LatLng(40.2, 32.7)
];
var markers = [];
var path = [];
for (var i = 0; i < points.length; ++i) {
var marker = new google.maps.Marker({map: map, position: points[i]});
markers.push(marker);
path.push(marker.position);
}
var polyline = new google.maps.Polyline({
path: path,
strokeColor: "#FF0000"
});
polyline.setMap(map);
}
Upvotes: 1