-3

I need to draw path between multiple points on map. I use below code to draw path , but it won't work and won't draw any path. why and how can I solve this?

    var myTrip = [], waypts=[];    
                        myTrip.push(new google.maps.LatLng(32.6384014, 51.65132887000004));
                        waypts.push({
                            location: new google.maps.LatLng(32.6384014, 51.65132887000004),
                            stopover: true
                        });

myTrip.push(new google.maps.LatLng(32.63727025, 51.65345639999998));
                        waypts.push({
                            location: new google.maps.LatLng(32.63727025, 51.65345639999998),
                            stopover: true
                        });

myTrip.push(new google.maps.LatLng(32.6367726, 51.65345639999998));
                        waypts.push({
                            location: new google.maps.LatLng(32.6367726, 51.65677270000003),
                            stopover: true
                        });                       

                    var directionsService = new google.maps.DirectionsService();
                    var directionsDisplay = new google.maps.DirectionsRenderer(
                    {
                        suppressMarkers: true,
                        suppressInfoWindows: true
                    });
                    directionsDisplay.setMap(map);
                    var request = {
                        origin: myTrip[0],
                        destination: myTrip[myTrip.length - 1],
                        waypoints: waypts,
                        travelMode: google.maps.DirectionsTravelMode.DRIVING
                    };
                    directionsService.route(request, function (response, status) {
                        if (status == google.maps.DirectionsStatus.OK) {

                            directionsDisplay.setDirections(response);
                        }
                    });

here is my jsfiddle code : jsfiddle geomap

Salix alba
  • 7,536
  • 2
  • 32
  • 38
mina morsali
  • 778
  • 1
  • 16
  • 29
  • Please provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that demonstrates the issue. The [posted code works for me](http://jsfiddle.net/vpr1dkxy/) – geocodezip Jun 27 '15 at 11:37
  • I provide my jsfiddle code. It work when points is statis , but when I fill points dynamically It wont work with waypoints in request – mina morsali Jun 27 '15 at 12:24
  • Your fiddle works for me. How many waypoints? How do you "fill points dynamically"? – geocodezip Jun 27 '15 at 12:31
  • 15 points , I add points same as above static example code. – mina morsali Jun 27 '15 at 12:39
  • I think this problem cause of points count , when I decrease point numbers path draw successfully. How can I manage too many points? – mina morsali Jun 27 '15 at 12:44
  • possible duplicate of [JavaScript Google Maps polylines : issue in connecting all given GPS locations](http://stackoverflow.com/questions/27609872/javascript-google-maps-polylines-issue-in-connecting-all-given-gps-locations/27610234#27610234) – geocodezip Jun 27 '15 at 13:06

1 Answers1

0

My problem is from the way points number , from google reference : google map developers reference

The maximum allowed waypoints is 8, plus the origin, and destination. Google Maps API for Work customers are allowed 23 waypoints, plus the origin, and destination. Waypoints are not supported for transit directions.

mina morsali
  • 778
  • 1
  • 16
  • 29