ios - Autoshow the Directions when editing both labels and delete last "drawPath" -


i want autoshow directions when editing both labels , delete last "drawpath" without hitting button.

func drawpath(startlocation: cllocation, endlocation: cllocation) { let origin = "(startlocation.coordinate.latitude),(startlocation.coordinate.longitude)" let destination = "(endlocation.coordinate.latitude),(endlocation.coordinate.longitude)"

    let url = "https://maps.googleapis.com/maps/api/directions/json?origin=\(origin)&destination=\(destination)&mode=driving"      alamofire.request(url).responsejson { response in          print(response.request any)  // original url request         print(response.response any) // http url response         print(response.data any)     // server data         print(response.result any)   // result of response serialization          let json = json(data: response.data!)         let routes = json["routes"].arrayvalue          // print route using polyline         route in routes         {             let routeoverviewpolyline = route["overview_polyline"].dictionary             let points = routeoverviewpolyline?["points"]?.stringvalue             let path = gmspath.init(fromencodedpath: points!)             let polyline = gmspolyline.init(path: path)             polyline.strokewidth = 4             polyline.strokecolor = uicolor.red             polyline.map = self.googlemaps         }      } }    // mark: when start location tap, open search location @ibaction func opensartlocation(_ sender: uibutton) {        let autocompletecontroller = gmsautocompleteviewcontroller()     autocompletecontroller.delegate = self      // selected location     locationselected = .startlocation      // change text color     uisearchbar.appearance().settextcolor(color: uicolor.black)     self.locationmanager.stopupdatinglocation()      self.present(autocompletecontroller, animated: true, completion: nil) }  // mark: when destination location tap, open search location  @ibaction func opendestinationlocation(_ sender: uibutton) {       let autocompletecontroller = gmsautocompleteviewcontroller()     autocompletecontroller.delegate = self      // selected location     locationselected = .destinationlocation      // change text color     uisearchbar.appearance().settextcolor(color: uicolor.black)     self.locationmanager.stopupdatinglocation()      self.present(autocompletecontroller, animated: true, completion: nil) }   // mark: show direction button      @ibaction func show(_ sender: uibutton) {         // when button direction tapped, must call drawpath func     self.drawpath(startlocation: locationstart, endlocation: locationend)   } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -