Visva
Visva

Reputation: 194

Multiple polyline between two point in google map

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

Answers (2)

Borja
Borja

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

Related Questions