Reputation: 4313
My goal is to put a text field on top of google maps iOS but seems like it doesn't work
When I run the app, the text field doesn't exist on top of Google Maps
The code
import UIKit
import GoogleMaps
class ViewController: UIViewController {
@IBOutlet var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Upvotes: 1
Views: 2473
Reputation: 1906
Here is the super easy solution to do the same with storyboard
.
Add Constraints
Note : if you have issues to view GIF, please download and separate frame
Output
Upvotes: 3
Reputation: 3415
Instead of adding UITextField
as subView
of MapView
, add both in a same UIView
& just put the UITextfield
over MApView
. Change it like this
Upvotes: 1