andre0707 / MKMultiPoint-to-UIView

Mapping visible MKMultiPoint lines from a map to a UIBezierPath.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MKMultiPoint to UIView

A simple Swift demo project how to convert a route on a map to a path which will be added as a layer on a new UIView. The map is a standard MKMapView map with a standard MKPolyline overlay added.

The needed extensions are based on MKMultiPoint which MKPolyline subclasses from.

The added function calculatePath on MKMultiPoint does the main convertion from CLLocationCoordinate2D to CGPoint and returns the path as a UIBezierPath.

MainVC.swift

The MainVC is a simple UIViewController which embeds a MKMapView. It also adds a rectangle overlay and a button to create a view with the path from the rectangle. See the following screenshot of it:

Start view

After clicking the wrench button, the view with the path will be created

Added view with path

Moving the underlaying map a little around to match the postion:

Moved map

Projects using MKMultiPoint to UIView

I used this MKMultiPoint to UIView converter in my Workout Map app.

About

Mapping visible MKMultiPoint lines from a map to a UIBezierPath.

License:MIT License


Languages

Language:Swift 100.0%