2016-12-28 1 views
0

ich die unten zum Zeichnen eines Pfades während eines Laufes/geht mit Apple MapsSwift 3 eine Polylinie mit Google Maps ziehen während des Laufes

extension NewRunViewController: MKMapViewDelegate { 
    func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! { 
    if !overlay.isKindOfClass(MKPolyline) { 
     return nil 
    } 

    let polyline = overlay as! MKPolyline 
    let renderer = MKPolylineRenderer(polyline: polyline) 
    renderer.strokeColor = UIColor.blueColor() 
    renderer.lineWidth = 3 
    return renderer 
    } 
} 

Jedoch versuche ich es mit Google Maps zu tun gefunden haben und ‚kann Ich finde die Lösung. Viele und viele Antworten sind für Apple Maps, aber nicht viel auf Google Maps.

+0

Versuchen Sie Polylinie mit dem Benutzer Lage ziehen Sie wollen? –

+0

@RajeshkumarR Ja, zeichnen Sie eine Polylinie, während er sich bewegt – asheyla

+0

In der Delegate-Methode 'didUpdateLocations' von locationManager verwenden Sie wie folgt' path.add (locations.last.coordinate) ' –

Antwort

0

dieses

let path = GMSMutablePath() 
//Change coordinates 
path.add(CLLocationCoordinate2D(latitude: -33.85, longitude: 151.20)) 
path.add(CLLocationCoordinate2D(latitude: -33.70, longitude: 151.40)) 
path.add(CLLocationCoordinate2D(latitude: -33.73, longitude: 151.41)) 
let polyline = GMSPolyline(path: path) 
polyline.strokeColor = UIColor.blue 
polyline.strokeWidth = 3.0 
polyline.map = mapView 
Verwandte Themen