title: Is there any limits of waypoints to draw a route in google map for iOS
body: <p>For iOS its showing that we can't use more than 10 waypoints to draw a route (including source and destination waypoints).</p>
  
  <p>for android there is no limit for the waypoints.</p>
  
  <p>I used the following code to draw a route :</p>
  
  <pre><code>func getDirections(origin: String!, destination: String!, waypoints: Array&lt;String&gt;!, travelMode: AnyObject!, completionHandler: ((_ status: String, _ success: Bool) -&gt; Void)?) {
          if let originLocation = origin {
              if let destinationLocation = destination {
                  var directionsURLString = baseURLDirections + "origin=" + originLocation + "&amp;destination=" + destinationLocation
                  if let routeWaypoints = waypoints {
                      directionsURLString += "&amp;waypoints=optimize:true"
  
                  for waypoint in routeWaypoints {
                      directionsURLString += "|" + waypoint
                  }
              }
              print(directionsURLString)
              directionsURLString = directionsURLString.addingPercentEscapes(using: String.Encoding.utf8)!
              let directionsURL = NSURL(string: directionsURLString)
              DispatchQueue.main.async( execute: { () -&gt; Void in
                  let directionsData = NSData(contentsOf: directionsURL! as URL)
                  do{
                      let dictionary: Dictionary&lt;String, AnyObject&gt; = try JSONSerialization.jsonObject(with: directionsData! as Data, options: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary&lt;String, AnyObject&gt;
  
                      let status = dictionary["status"] as! String
  
                      if status == "OK" {
                          self.selectedRoute = (dictionary["routes"] as! Array&lt;Dictionary&lt;String, AnyObject&gt;&gt;)[0]
                          self.overviewPolyline = self.selectedRoute["overview_polyline"] as! Dictionary&lt;String, AnyObject&gt;
  
                          let legs = self.selectedRoute["legs"] as! Array&lt;Dictionary&lt;String, AnyObject&gt;&gt;
  
                          let startLocationDictionary = legs[0]["start_location"] as! Dictionary&lt;String, AnyObject&gt;
                          self.originCoordinate = CLLocationCoordinate2DMake(startLocationDictionary["lat"] as! Double, startLocationDictionary["lng"] as! Double)
  
                          let endLocationDictionary = legs[legs.count - 1]["end_location"] as! Dictionary&lt;String, AnyObject&gt;
                          self.destinationCoordinate = CLLocationCoordinate2DMake(endLocationDictionary["lat"] as! Double, endLocationDictionary["lng"] as! Double)
  
                          let originAddress = legs[0]["start_address"] as! String
                          let destinationAddress = legs[legs.count - 1]["end_address"] as! String
  
                          let originMarker = GMSMarker(position: self.originCoordinate)
                          originMarker.map = self.mapView
                          originMarker.icon = UIImage(named: "mapIcon")
                          originMarker.title = originAddress
  
                          let destinationMarker = GMSMarker(position: self.destinationCoordinate)
                          destinationMarker.map = self.mapView
                          destinationMarker.icon = UIImage(named: "mapIcon")
                          destinationMarker.title = destinationAddress
  
                          if waypoints != nil &amp;&amp; waypoints.count &gt; 0 {
                              for waypoint in waypoints {
                                  let lat: Double = (waypoint.components(separatedBy: ",")[0] as NSString).doubleValue
                                  let lng: Double = (waypoint.components(separatedBy: ",")[1] as NSString).doubleValue
  
                                  let marker = GMSMarker(position: CLLocationCoordinate2DMake(lat, lng))
                                  marker.map = self.mapView
                                  marker.icon = UIImage(named: "mapIcon")
  
                              }
                          }
  
                          let route = self.overviewPolyline["points"] as! String
  
                          let path: GMSPath = GMSPath(fromEncodedPath: route)!
                          let routePolyline = GMSPolyline(path: path)
                          routePolyline.map = self.mapView
                          routePolyline.strokeColor = UIColor(red: 44, green: 134, blue: 200)
                          routePolyline.strokeWidth = 3.0
                      }
                      else {
                          print("status")
                          //completionHandler(status: status, success: false)
                      }
                  }
                  catch {
                      print("catch")
  
                      // completionHandler(status: "", success: false)
                  }
              })
          }
          else {
              print("Destination is nil.")
              //completionHandler(status: "Destination is nil.", success: false)
          }
      }
      else {
          print("Origin is nil")
          //completionHandler(status: "Origin is nil", success: false)
      }
  }
  </code></pre>