Skip to content

Instantly share code, notes, and snippets.

@DejanEnspyra
Created October 3, 2017 19:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DejanEnspyra/49d2de95609f67f0050e18593008708b to your computer and use it in GitHub Desktop.
Save DejanEnspyra/49d2de95609f67f0050e18593008708b to your computer and use it in GitHub Desktop.
Polygon Google Maps iOS SDK
func polygon(){
// Create a rectangular path
let rect = GMSMutablePath()
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0))
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2))
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2))
// Create the polygon, and assign it to the map.
let polygon = GMSPolygon(path: rect)
polygon.fillColor = UIColor(red: 0.25, green: 0, blue: 0, alpha: 0.2);
polygon.strokeColor = .black
polygon.strokeWidth = 2
polygon.map = mapView
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment