Skip to content

Swift implementation of the google's polyline algorithm

License

Notifications You must be signed in to change notification settings

twox/polylineEncoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

polylineEncoder

Swift implementation of the google's polyline algorithm https://developers.google.com/maps/documentation/utilities/polylinealgorithm
Source of code: https://github.com/dionysis560/polylineAlgorithm

USE

    var path: GMSPath... // The path that describes a polyline. 
    mapView.clear() // Clear Google Map

    let pline = PolyLineEncoder() 
    for index in 0 ..< path.count() - 1 {
        let coordinate = path.coordinate(at: index) 
        pline.addPoint(lat: coordinate.latitude, lon: coordinate.longitude) 
    }
    pline.encode() // Encode path to String
    print(pline.toString()) // Show encoded string of polyline

    // Demo create polygon from this path
    let pathNew = GMSPath(fromEncodedPath: pline.toString())
    let polygon = GMSPolygon(path: pathNew)
    polygon.map = mapView

About

Swift implementation of the google's polyline algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages