sinusGob
sinusGob

Reputation: 4313

how to put a text field on top of google maps iOS

My goal is to put a text field on top of google maps iOS but seems like it doesn't work

enter image description here

When I run the app, the text field doesn't exist on top of Google Maps

enter image description here

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

Answers (2)

Bhavesh Dhaduk
Bhavesh Dhaduk

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

enter image description here

Output

<code>enter image description here</code>

Upvotes: 3

Amal T S
Amal T S

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

Related Questions