Coders Packet

Example of adding multiple marker on Map using SwiftUI MapKit

By Faruque Ahamed Mollick

This is an example to show you how to add multiple locations using MapAnnotation() in SwiftUI. Using the annotation we have added a custom market on the SwiftUI map.

The complete source code is available as a single SwiftUI file in the zip code. In the code, we are using a custom map marker to mark places on the MAP.

In this mini project, we are using the built-in MapKit library that comes with Xcode.

First, we have created our structure for the skeleton of this project. After that, we created an array containing multiple places or locations for the map marker. Each marker item in the array contains the name of the place and coordinate.

After you download and unzip this project, you will get a Swift file ContentView.swift. In this file, all the SwiftUI code is written.

You can customize the code depending on your requirement. You can add more places in the map.

I have used circles as the marker. You can place any other icon, shape, image anything else that will act as the marker on the SwiftUI map.

Download Complete Code


No comments yet