Google Maps Integration iOS Swift. Part 2

Description: — GoogleMaps with custom theme and Clustering. iOS Swift

Next Step! We need to Implement CLLocationManager to ask user location usage, and to get his current location:

  1. I decide to create some object which will be responsive for this task, and called him LocationManager. But before we need to create two protocols to manage all needed operations, firsts for input actions, second-one should be a delegate to give us some callbacks (like didUpdateLocations.. etc). So our Protocol should be something like this:
import CoreLocation

LocationServiceDelegate. — contains two methods one for react to Location update. — updateLocation, and one to react on authorizationStatus changed
Actually if you need to implement some reaction on this events, also delegate conformed to AnyObject to let us give weak modifier for objects of LocationServiceDelegate type

LocationServiceProtocol- contains three methods and confirmed to CLLocationManagerDelegate:

setDelegate — it’s delegate setter

startLocationsService — will notify our service the he can start updatingLocations, requestAuthorization, etc…

stopLocationService — will notify out service that we need to stop updatingLocation, deist locationManager, etc…

So our Location Service will be look loke this:

final class LocationService: NSObject, LocationServiceProtocol {

Great, now lets create instance of Location Service for this time inside of MapViewController.swift, and then we can startLocationService() on viewDidLoad and stopLocationService, let’s say on viewWillDissapear:

import UIKit

Nice, let’s run the app, and we should see next screen:

Cool! We done with it

Link to 1 part

Link to 3 part

Lint to 4 part

Link to 5 part

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store