IOS TOPICS

IOS Introduction
Swift UI Label
Swift UI Button
Swift UI Text Field
Swift UI Slider
Swift UI Switch
Swift UI Stepper
Swift UI Date Picker
Swift UI Segmented Control
Views
Table View
Collection Views
SCROLL VIEW
iOS Content View
iOS View Controllers
iOS Bar interface
iOS Navigation interface
iOS Architect Pattern
iOS Libraries
iOS Web request and parsing
iOS user defaults
iOS Coredata and database

Map View


Map View

The MapView object may be used to display an embeddable map interface in iOS apps. It's comparable to the one given by the Google Maps apps. It's a member of the MKMapView class, which is descended from the UIView class.

    1.class MKMapView : UIView

Setting the starting region in the map in MapView Example 1

We'll establish the map view's starting region in this example. To do so, we'll need to instantiate the CLLocation class and construct a location object. The following syntax may be used to construct the location object.

    let location = CLLocation(latitude: CLLocationDegrees, longitude: CLLocationDegrees#)

This procedure accepts the latitude and longitude of the specific place as two parameters. Latitude and longitude are instances of the CLLocationDegrees class in MapKit.

ViewController.swift

import UIKit import MapKit class ViewController: UIViewController { @IBOutlet weak var mapView: MKMapView! CLLocation is a placeholder for a location (latitude: 28.613939, longitude: 77.209023) let region_radious = 10000 override func viewDidLoad() { super.viewDidLoad() After loading the view, do any extra configuration. centreMap(location: location) } func centreMap(location: CLLocation){ let MK be the region (location.coordinate,latitudinal) CoordinateRegion(center: location.coordinate,latitudinal) CoordinateRegion(center: location.coordinate CLLocationDistance(region radius), longitudinal, CLLocationDistance(region radius), CLLocationDistance(region radius CLLocationDistance(region radius) in metres mapView.setRegion(region, animated: true) } }