I am very new to both iOS developing and using the google maps sdk. I am using Xcode for my current project. I have added my API keys in the appropriate place.
So far I have this:
import UIKit import GoogleMaps import GooglePlaces
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func loadView() {
let camera = GMSCameraPosition.cameraWithLatitude(36.2108, longitude: -81.6774, zoom: 15.0)
let mapView = GMSMapView.mapWithFrame(.zero, camera: camera)
mapView.myLocationEnabled = true
if let mylocation = mapView.myLocation {
print("User's location: \(mylocation)")
} else {
print("User's location is unknown")
}
self.view = mapView
mapView.mapType = kGMSTypeTerrain
mapView.indoorEnabled = true
let mapInsets = UIEdgeInsets(top: 100.0, left: 0.0, bottom: 0.0, right: 0.0)
mapView.padding = mapInsets
//Creates a marker in the center of the map.
//let marker = GMSMarker()
//marker.position = CLLocationCoordinate2D(latitude: 36.2108, longitude: -81.6774)
//marker.title = "ASU"
//marker.snippet = "Boone, NC"
//marker.map = mapView
}
}
My problem is that when I run the app using the simulator, it doesn't show my current gps location anywhere. It does successfully take me to the specified coordinates, it zooms correctly, and it shows the map as the typography map.
So my questions:
What am I doing wrong thats making my current location not show up? (it never asks to have permission)
How can I make my map appear in the background? Like I added the padding to the top so i could add a button through the storyboard but the button did not show up.
Thanks all!
The location on the simulator does not always work, you can: