I'm trying to add a map using GMSMapView
but I'm getting errors when I create an outlet for the view.
The following is the code snippet:
import UIKit
import GoogleMaps
class MapViewController: UIViewController {
@IBOutlet weak var mapVIew: GMSMapView!
@IBOutlet weak var mapCenterPinImage: UIImageView!
@IBOutlet weak var pinImageVerticalConstraint: NSLayoutConstraint!
var searchedTypes = ["bakery", "bar", "cafe", "grocery_or_supermarket", "restaurant"]
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "Types Segue" {
let navigationController = segue.destinationViewController as! UINavigationController
let controller = navigationController.topViewController as! TypesTableViewController
controller.selectedTypes = searchedTypes
controller.delegate = self
}
}
}
I'm getting the following errors at line
@IBOutlet weak var mapVIew: GMSMapView!:
Please can someone help me out
The marked answer is not the correct answer to this problem. In case anyone else hits this, the problem is the framework needed is not imported. In this case GoogleMaps. The fix for this is, at the top of file add
import GoogleMaps
Another example is if you get the error after adding an MkMapView.
@IBOutlet weak var mapView: MKMapView
For this you'll have to import MapKit
import MapKit
Note : Updating this answer to avoid misunderstanding as I have answered wrong earlier. Thanks @Inn0vative1 for pointing out error
For this you'll have to import MapKit
import MapKit
Your viewController did not confirm the protocol, Please conform the CLLocationManagerDelegate
protocol
class MapViewController: UIViewController,CLLocationManagerDelegate {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With