# MapKit Tutorial: Overlay Views

**URL:** <https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881>\
**Category:** 🎓 Courses & Articles\
**Created:** [August 30, 2017, 4:01pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881 "2017-08-30T16:01:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![owenb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/owenb/32/101345_2.png) [@owenb](https://forums.kodeco.com/u/owenb)\
**Post date:** [August 30, 2017, 4:01pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/1 "2017-08-30T16:01:56Z")

</div>

Learn how to add satellite and hybrid maps, custom images, annotations, lines, boundaries and circles to the standard map using MapKit Overlay Views.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/425-mapkit-tutorial-overlay-views](https://www.raywenderlich.com/425-mapkit-tutorial-overlay-views)

---

<div class="post-metadata">

**Author:** ![nmb225](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nmb225/32/71005_2.png) [@nmb225](https://forums.kodeco.com/u/nmb225)\
**Post date:** [August 30, 2017, 9:51pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/2 "2017-08-30T21:51:32Z")

</div>

Sorry if this is a noob question…any idea why I’m getting the error ‘Return from initializer without initializing all stored properties – self.boundary not initialized’ in the Park class? I had the .map closure in there (even copied and pasted from the tutorial thinking I missed something), and also tried replacing it with a loop like in the original tutorial like this:

```
let cgPoints = boundaryPoints.map { CGPointFromString($0) }
        var boundaryTmp: [CLLocationCoordinate2D] = []
        for i in 0...cgPoints.count - 1 {
            let j = CLLocationCoordinate2DMake(CLLocationDegrees(cgPoints[i].x), CLLocationDegrees(cgPoints[i].y))
            boundaryTmp.append(j)
        }
        self.boundary = boundaryTmp

```

Thanks!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 31, 2017, 10:39am UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/3 "2017-08-31T10:39:24Z")

</div>

@owenb Could you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![lars](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lars/32/106129_2.png) [@lars](https://forums.kodeco.com/u/lars)\
**Post date:** [August 31, 2017, 11:16am UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/4 "2017-08-31T11:16:12Z")

</div>

You probably forgot to give the ivar an initial value…

var boundary: [CLLocationCoordinate2D] **= []**

---

<div class="post-metadata">

**Author:** ![owenb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/owenb/32/101345_2.png) [@owenb](https://forums.kodeco.com/u/owenb)\
**Post date:** [August 31, 2017, 1:13pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/5 "2017-08-31T13:13:29Z")

</div>

I agree with lars, be sure boundary is initialized in its declaration, or if you prefer, initialize it in init().

---

<div class="post-metadata">

**Author:** ![nmb225](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nmb225/32/71005_2.png) [@nmb225](https://forums.kodeco.com/u/nmb225)\
**Post date:** [August 31, 2017, 1:29pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/6 "2017-08-31T13:29:43Z")

</div>

@lars @owenb Thanks guys! What a simple thing I overlooked. Looking forward to finishing this today. Great post!

---

<div class="post-metadata">

**Author:** ![thegamingart](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thegamingart/32/104125_2.png) [@thegamingart](https://forums.kodeco.com/u/thegamingart)\
**Post date:** [September 4, 2017, 10:53pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/7 "2017-09-04T22:53:37Z")

</div>

Did anyone do a technical edit of this posting?

`mapView.mapType = MKMapType.init(rawValue: UInt(sender.selectedSegmentIndex)) ?? .standard`

You should definitely not be calling `.init` directly like that at all.

---

<div class="post-metadata">

**Author:** ![thegamingart](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thegamingart/32/104125_2.png) [@thegamingart](https://forums.kodeco.com/u/thegamingart)\
**Post date:** [September 4, 2017, 11:02pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/8 "2017-09-04T23:02:21Z")

</div>

It should be noted that there are some major performance issues that are reflected when using MapKit on the Xcode 9 betas (sims) as seen [here](https://forums.developer.apple.com/thread/83570). It may be a good call to call this out in the above posting as the region is rarely, if at all, set and animated.

---

<div class="post-metadata">

**Author:** ![thegamingart](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thegamingart/32/104125_2.png) [@thegamingart](https://forums.kodeco.com/u/thegamingart)\
**Post date:** [September 5, 2017, 1:08am UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/9 "2017-09-05T01:08:47Z")

</div>

`MKOverlayRenderer` also inherits from `NSObject`. It has no direct association to a `UIView`. I’m not quite sure why the subclass doesn’t indicate this an why it’s referenced as being a `UIView` child. A renderer != a view.

---

<div class="post-metadata">

**Author:** ![thegamingart](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thegamingart/32/104125_2.png) [@thegamingart](https://forums.kodeco.com/u/thegamingart)\
**Post date:** [September 5, 2017, 1:18am UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/10 "2017-09-05T01:18:34Z")

</div>

Should likely remove the `;` after `break;`

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [April 26, 2018, 10:00pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/12 "2018-04-26T22:00:30Z")

</div>

Opened on April 26, 2018, 10:00pm UTC



---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [April 26, 2018, 10:00pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/13 "2018-04-26T22:00:36Z")

</div>

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [April 26, 2018, 10:00pm UTC](https://forums.kodeco.com/t/mapkit-tutorial-overlay-views/33881/14 "2018-04-26T22:00:39Z")

</div>

Closed on April 26, 2018, 10:00pm UTC


