7

Dears,

I want to make the user restricted to choose places only from the GMSPlacepicker and not giving them the option to press the "Select this location" which send Long & Lat only without place name.

So my question is hot to remove the "Select this location" Button in the GMSPlacePicker Dialog.

Here is what I mean..

enter image description here

Here is the code written..

    @IBAction func LocationChooserPressed(_ sender: AnyObject) {

    let center = CLLocationCoordinate2DMake((locationManager.location?.coordinate.latitude)!, (locationManager.location?.coordinate.longitude)!)
    let northEast = CLLocationCoordinate2DMake(center.latitude + 0.001, center.longitude + 0.001)
    let southWest = CLLocationCoordinate2DMake(center.latitude - 0.001, center.longitude - 0.001)
    let viewport = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
    let config = GMSPlacePickerConfig(viewport: viewport)
    placePicker = GMSPlacePicker(config: config)


    placePicker?.pickPlace( callback: { (place: GMSPlace?, error: Error?) -> Void in
        if let error = error {
            print("Pick Place error: \(error.localizedDescription)")
            return
        }

        if let place = place {
            self.nameLabel.text = place.name
            self.addressLabel.text = place.formattedAddress!.components(separatedBy: ", ").joined(separator: "\n")
            self.chosenLong = String(place.coordinate.longitude)
            self.chosenLat = String(place.coordinate.latitude)

        } else {
            //self.nameLabel.text = "No place selected"
            self.addressLabel.text = ""
        }
    })
}

I believe there should be configuration or flag that could remove this selection.

Your support is highly appreciated. Thank you

Mostafa
  • 1,522
  • 2
  • 18
  • 34

0 Answers0