Reputation: 194
i am working on google map for my project. i need to draw multiple lines between two place(points). I don't know, is it possible?. please any one help me.
Upvotes: 1
Views: 2075
Reputation: 3610
To draw line between two points using the following function to which I pass the map and lat and long in the first point and second point.
var mapOptions = {
zoom: zoom,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas_'+id), mapOptions);
function poliLines(map, latPointBefore, lonPointBefore, latPointAfter, lonPointAfter){
var routes = [
new google.maps.LatLng(latPointBefore, lonPointBefore)
,new google.maps.LatLng(latPointAfter, lonPointAfter)
];
var polyline = new google.maps.Polyline({
path: routes
, map: map
, strokeColor: '#ff0000'
, strokeWeight: 5
, strokeOpacity: 0.5
, clickable: false
});
}
Upvotes: 0
Reputation: 12161
There is no multi line support in google maps API ... but you can do it with javascript.
A polyline example:
https://developers.google.com/maps/documentation/javascript/examples/polyline-simple
The API:
https://developers.google.com/maps/documentation/javascript/reference?hl=pt-BR#Polyline
More examples:
https://developers.google.com/maps/documentation/javascript/examples/
Upvotes: 1