Swift Google Place Autocomplete not working wtih Google Maps - ios

I am using a search bar to use Google Place Autocomplete feature. However, it is not working when I am putting the search bar on top of GMSMapView. It works completely fine when I comment out loadView() function. Is there a way to use the place autocomplete with Google map?
import UIKit
import GoogleMaps
class ViewController: UIViewController {
var resultsViewController: GMSAutocompleteResultsViewController?
var searchController: UISearchController?
var resultView: UITextView?
override func loadView() {
let camera = GMSCameraPosition.cameraWithLatitude(1.285, longitude: 103.848, zoom: 12)
let mapView = GMSMapView.mapWithFrame(.zero, camera: camera)
self.view = mapView
}
override func viewDidLoad() {
super.viewDidLoad()
resultsViewController = GMSAutocompleteResultsViewController()
resultsViewController?.delegate = self
searchController = UISearchController(searchResultsController: resultsViewController)
searchController?.searchResultsUpdater = resultsViewController
let subView = UIView(frame: CGRectMake(0, 65.0, 350.0, 45.0))
subView.addSubview((searchController?.searchBar)!)
self.view.addSubview(subView)
searchController?.searchBar.sizeToFit()
searchController?.hidesNavigationBarDuringPresentation = false
// When UISearchController presents the results view, present it in
// this view controller, not one further up the chain.
self.definesPresentationContext = true
}
}
// Handle the user's selection.
extension ViewController: GMSAutocompleteResultsViewControllerDelegate {
func resultsController(resultsController: GMSAutocompleteResultsViewController,
didAutocompleteWithPlace place: GMSPlace) {
searchController?.active = false
// Do something with the selected place.
print("Place name: ", place.name)
print("Place address: ", place.formattedAddress)
print("Place attributions: ", place.attributions)
}
func resultsController(resultsController: GMSAutocompleteResultsViewController,
didFailAutocompleteWithError error: NSError){
// TODO: handle the error.
print("Error: ", error.description)
}
// Turn the network activity indicator on and off again.
func didRequestAutocompletePredictionsForResultsController(resultsController: GMSAutocompleteResultsViewController) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
}
func didUpdateAutocompletePredictionsForResultsController(resultsController: GMSAutocompleteResultsViewController) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
}
}
The code above is from https://developers.google.com/maps/documentation/ios-sdk/map and https://developers.google.com/places/ios-api/autocomplete. I copied these for testing and is still not working.

Sorry, I don't have the reputation to write comments yet, but I think this could help you to figure out the issue.
First call the super.loadView() and when you initialize the GMSMapView you must set a frame size. Finally add the mapView to the subview.
override func loadView() {
super.loadView()
let camera = GMSCameraPosition.cameraWithLatitude(1.285, longitude: 103.848, zoom: 12)
let mapView = GMSMapView.mapWithFrame(self.view.frame, camera: camera)
self.view.addSubview(mapView)
}

Related

SearchBar not showing on navigation bar

I'm trying to show the search bar on the navigation bar.
The search bar should show me the search results and then show me the map navigation details.
I tried the same code to another project and seems to work.
This happens with the latest version of Xcode 10 and iOS 12.
here is the code:
// Protocol for dropping a pin at a specified place
protocol HandleMapSearch: class {
func dropPinZoomIn(_ placemark:MKPlacemark)
}
class MapViewController: UIViewController {
#IBOutlet weak var mapView: MKMapView!
#IBAction func navigateButton(_ sender: Any) {
}
let locationManager = CLLocationManager()
var currentLocation: CLLocation?
var routeCoordinates = [CLLocationCoordinate2D]()
var resultSearchController: UISearchController!
var selectedPin: MKPlacemark?
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
mapView.showsUserLocation = true
let coordinateSpan = MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)
guard let userCoordinate = locationManager.location?.coordinate else { return }
let userRegion: MKCoordinateRegion = MKCoordinateRegion(center: userCoordinate, span: coordinateSpan)
// Zoom to user location
mapView.setRegion(userRegion, animated: true)
// Hide back button
self.navigationItem.setHidesBackButton(true, animated: false)
let locationSearchTable = storyboard!.instantiateViewController(withIdentifier: "LocationSearchTable") as! LocationSearchTable
resultSearchController = UISearchController(searchResultsController: locationSearchTable)
resultSearchController.searchResultsUpdater = locationSearchTable
let searchBar = resultSearchController!.searchBar
searchBar.sizeToFit()
searchBar.placeholder = "Search for places"
navigationItem.titleView = resultSearchController?.searchBar
resultSearchController.hidesNavigationBarDuringPresentation = false
resultSearchController.dimsBackgroundDuringPresentation = true
definesPresentationContext = true
locationSearchTable.mapView = mapView
locationSearchTable.handleMapSearchDelegate = self
}
I get no errors and not console log messages

Could not inset legal attribution from corner 4 swift

I am new to Xcode and mobile app. I am doing an app to find the current location. I tested it on the simulator and got this message in the console.
"Could not inset legal attribution from corner 4". What does it mean and how can I fix it?
import UIKit
import Alamofire
import AlamofireImage
import MapKit
import CoreLocation
class MapVC: UIViewController
#IBOutlet weak var mapView: MKMapView!
var locationManager = CLLocationManager()
let authorizationStatus = CLLocationManager.authorizationStatus()
let regionRadius: Double = 1000
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
locationManager.delegate = self
configureLocationServices()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func centerMapPressed(_ sender: Any) {
if authorizationStatus == .authorizedAlways || authorizationStatus == .authorizedWhenInUse{
centerMapOnUserLocation()
}
}
MKMapViewDelegate:
func centerMapOnUserLocation(){
guard let coordinate = locationManager.location?.coordinate else{return}
let coordinateRegion = MKCoordinateRegionMakeWithDistance(coordinate, regionRadius*2.0, regionRadius * 2.0 )
mapView.setRegion(coordinateRegion, animated: true)
}
CLLocationManagerDelegate:
func configureLocationServices(){
if authorizationStatus == .notDetermined{
locationManager.requestAlwaysAuthorization()
}else{
return}
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
centerMapOnUserLocation()
}
this issue occurs when the required information in the right form is not found. if your device i trying to get some location or some number a variable, and that a variable is required for afun.. the value is not set into a, but afun is called that this error occurs..
call your cell's coordinates in viewdidload without any other function.
Here is the simplest way to get your cell's position.
1. you should have updated privacies of the devices under infor.plist
Add following lines into your plist before closing tag
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Privacy - Location Always and When In Use Usage Description</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Privacy - Location Always Usage Description</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Privacy - Location When In Use Usage Description</string>
after that.. this is the simplest working code .. i'm happily using it with no issue..
import CoreLocation
import MapKit
class AddressVc: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {
#IBOutlet weak var map: MKMapView!
var locationManager = CLLocationManager()
here is code to move map in center for the required location
let latDelta:Double = 0.5
let lngDelta:Double = 0.5
let latitude:Double = 37.57554038
let longitude:Double = -122.40068475
let locationcoordinates = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
let zoomSpan = MKCoordinateSpan(latitudeDelta: latDelta, longitudeDelta: lngDelta)
let region = MKCoordinateRegion(center: locationcoordinates, span: zoomSpan)
self.map.setRegion(region, animated: true)
in the above code.. if you put device's lat and lng postions in latitude and lognitude that will move the map to your's devices's location.
now how to get device's location.
here is the code you can put into your viewDidLoad() function.
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
// device latitude = (locationManager.location?.coordinate.latitude)!
// device longitude = (locationManager.location?.coordinate.longitude)!
}
this is detect the device's latitude and longitude values. you can put them in above mentioned code..
Here is the full code.
import CoreLocation
import MapKit
class AddressVc: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {
#IBOutlet weak var map: MKMapView!
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
devicelatitude = (locationManager.location?.coordinate.latitude)!
devicelongitude = (locationManager.location?.coordinate.longitude)!
let latDelta:Double = 0.5
let lngDelta:Double = 0.5
let latitude:Double = devicelatitude
let longitude:Double = devicelongitude
let locationcoordinates = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
let zoomSpan = MKCoordinateSpan(latitudeDelta: latDelta, longitudeDelta: lngDelta)
let region = MKCoordinateRegion(center: locationcoordinates, span: zoomSpan)
self.map.setRegion(region, animated: true)
}
I hope this will help you.. if not.. there would be many other who are facing this issue.
==========================
With the simulator open, go to the DEBUG menu on the mac top bar, the last option is location, mine was showing this error when set to NONE. Set it Custom Location, first with you prompt you to a custom location on a new window, fill that, close the simulator, and relaunch the app. It should get the custom location from your code now. (andrecasarini credit)
This error occurs when the "Legal" link on the bottom left of the MapView is not within bounds or is obscured. There are similar errors for the map's scale and for the compass that appears when rotating.
Consider using size constraints or a safeAreaInset.
I believe the legal inset bug is in Apple's mapkit initialization code and unrelated to what we do when we use the code. Here's my reasoning.
If you use storyboards and the UIMapKit drag and drop module, the legal inset error pops up somewhere between the call to the initial call to application in the app delegate and the first viewDidLoad call, i.e., it's an OS error.
I got curious if I could work around it and wrote a version that doesn't use the storyboard editor. I was thinking that perhaps the editor was inserting some broken code into the app. My test app has two views, the start view and a second view with the map on it. The code is shown below. Don't be harsh, it's my first attempt at understanding what's going on with controllers views and subviews using programmatic views and subviews. It isn't pretty but it works to isolate the legal inset bug.
I started by building a new xcode project and deleting the storyboard. I then replaced the application function stub in appdelegate with the following code:
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.main.bounds)
let viewController = ViewController()
self.window?.rootViewController = viewController
self.window?.makeKeyAndVisible()
let mapView = mapViewController()
mapView.otherView = viewController
viewController.mapView = mapView
return true
}
Even though the mapView is created here, the legal inset error doesn't show up. What does show up are a couple of other messages about scale and compass having some sort of issue. Since I was focusing on the legal inset bug, I ignored them and moved on.
I then replaced the default view controller with code that created two subviews, one a subview that serves as a button to switch to the second view controller and the second subview that serves as "you're on the first view" marker view. That required figuring out how to handle a tap. The color changing code in the tap handler was initial "hello world. I see a tap" code and serves no other purpose.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController,CLLocationManagerDelegate {
let DynamicView = UIView()
let switchView = UIView(frame: CGRect(x: UIScreen.main.bounds.minX+10, y: UIScreen.main.bounds.minY+20, width: 40, height: 40))
public var mapView:mapViewController? = nil
public var otherView:UIViewController? = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = .white
DynamicView.backgroundColor = .yellow
DynamicView.layer.cornerRadius = 25
DynamicView.layer.borderWidth = 2
switchView.backgroundColor = .orange
switchView.layer.borderWidth = 2
var gR = UITapGestureRecognizer(target: self, action:#selector(self.handlebigTap(_:)))
DynamicView.addGestureRecognizer(gR)
gR = UITapGestureRecognizer(target: self, action:#selector(self.handlesmallTap(_:)))
switchView.addGestureRecognizer(gR)
self.view.addSubview(switchView)
self.view.addSubview(DynamicView)
DynamicView.translatesAutoresizingMaskIntoConstraints = false
let margins = view.layoutMarginsGuide
DynamicView.leadingAnchor.constraint(equalTo: margins.leadingAnchor, constant: 10).isActive = true
DynamicView.trailingAnchor.constraint(equalTo: margins.trailingAnchor, constant: 10).isActive = true
DynamicView.topAnchor.constraint(equalTo: margins.topAnchor, constant: 40).isActive = true
DynamicView.bottomAnchor.constraint(equalTo: margins.topAnchor, constant: 110).isActive = true
}
#objc func handlebigTap(_ sender: UITapGestureRecognizer) {
if ( self.DynamicView.backgroundColor == .green){
self.DynamicView.backgroundColor = .blue
} else {
self.DynamicView.backgroundColor = .green
}
}
#objc func handlesmallTap(_ sender: UITapGestureRecognizer) {
if ( self.switchView.backgroundColor == .orange){
self.switchView.backgroundColor = .blue
present(mapView!, animated: true, completion: nil)
} else {
self.switchView.backgroundColor = .orange
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
At this point, I checked to see if the first call to viewDidLoad triggered the legal inset error and saw that it did not. That meant the error was being triggered somewhere in the mapKit initialization code which was yet to be built. I simply copied and pasted the first viewController into a new file and called that mapViewController. I commented out the DynamicView code left over from the first controller and added the mapKit initialization code as shown here:
import UIKit
import MapKit
import CoreLocation
class mapViewController: UIViewController,CLLocationManagerDelegate,MKMapViewDelegate {
let DynamicView = UIView(frame: CGRect(x: UIScreen.main.bounds.maxX-110, y: UIScreen.main.bounds.maxY-110, width: 100, height: 100))
let switchView = UIView(frame: CGRect(x: UIScreen.main.bounds.minX+10, y: UIScreen.main.bounds.minY+20, width: 40, height: 40))
var mapView = MKMapView()
public var otherView:UIViewController? = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = .white
// DynamicView.backgroundColor = .yellow
// DynamicView.layer.cornerRadius = 25
// DynamicView.layer.borderWidth = 2
switchView.backgroundColor = .orange
switchView.layer.borderWidth = 2
var gR = UITapGestureRecognizer(target: self, action:#selector(self.handlebigTap(_:)))
DynamicView.addGestureRecognizer(gR)
gR = UITapGestureRecognizer(target: self, action:#selector(self.handlesmallTap(_:)))
switchView.addGestureRecognizer(gR)
self.view.addSubview(switchView)
// self.view.addSubview(DynamicView)
// mapView.frame = CGRect(x: 10, y: 60, width: view.frame.size.width-20, height: 300)
mapView.mapType = MKMapType.standard
mapView.isZoomEnabled = true
mapView.isScrollEnabled = true
view.addSubview(mapView)
mapView.translatesAutoresizingMaskIntoConstraints = false
let margins = view.layoutMarginsGuide
mapView.leadingAnchor.constraint(equalTo: margins.leadingAnchor, constant: 10).isActive = true
mapView.trailingAnchor.constraint(equalTo: margins.trailingAnchor, constant: 0).isActive = true
mapView.topAnchor.constraint(equalTo: margins.topAnchor, constant: 45).isActive = true
mapView.bottomAnchor.constraint(equalTo: margins.bottomAnchor, constant: -20).isActive = true
}
#objc func handlebigTap(_ sender: UITapGestureRecognizer) {
if ( self.DynamicView.backgroundColor == .green){
self.DynamicView.backgroundColor = .blue
} else {
self.DynamicView.backgroundColor = .green
}
}
#objc func handlesmallTap(_ sender: UITapGestureRecognizer) {
if ( self.switchView.backgroundColor == .orange){
self.switchView.backgroundColor = .blue
dismiss(animated: true, completion: nil)
} else {
self.switchView.backgroundColor = .orange
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
}
}
I ran the above code and stepped through looking for the legal inset message to show up. This is the offending line:
mapView.frame = CGRect(x: 10, y: 60, width: view.frame.size.width-20, height: 300)
As soon as the view is framed, the error message comes out. Doesn't matter what dimensions you give the view, the message appears. OK.... Maybe the message expects a constraint based framing instead of hard coded per the offending line.
I commented out the line and added constraints to the view and still the error popped up.
At this point I gave up. I couldn't figure out how to configure a map view so the error message doesn't show up. Hopefully Apple will pipe up and say something at this point or someone else will pick up the baton to see if there's a way to configure mapkit to stop spewing error messages.
As for myself at least I learned how to dynamically add views, subviews, gesture recognizers and constraints so my time was profitably spent chasing the bug. Thanks to all who posted sample dynamic view code, gesture recognition code, subview code and constraint code. You may recognize a bit of your code here.
You have not typed in an opening curly bracket for your MapVC Class:
your code:
class MapVC: UIViewController
to fix:
class MapVC: UIViewController {

Google Places API Warning

Can anyone help how to solve this warning in Swift3 while using Google Places?
"Places API warning: A delegate has not been set on an instance of GMSAutocompleteResultsViewController before use. Note that this may result in undefined behavior such as being unable to dismiss screens, not being notified of selections, and being unable to correctly manage object lifecycle."
I basically followed the tutorial in https://developers.google.com/places/ios-api/autocomplete [Add a search bar to the top of a view]
Code:
import UIKit[enter image description here][1]
import GooglePlaces
class LocationTabViewController: UIViewController {
var resultsViewController: GMSAutocompleteResultsViewController?
var searchController: UISearchController?
var resultView: UITextView?
override func viewDidLoad() {
super.viewDidLoad()
resultsViewController = GMSAutocompleteResultsViewController()
resultsViewController?.delegate = self as? GMSAutocompleteResultsViewControllerDelegate
searchController = UISearchController(searchResultsController: resultsViewController)
searchController?.searchResultsUpdater = resultsViewController
let subView = UIView(frame: CGRect(x: 0, y: 65.0, width: 350.0, height: 45.0))
subView.addSubview((searchController?.searchBar)!)
view.addSubview(subView)
searchController?.searchBar.sizeToFit()
searchController?.hidesNavigationBarDuringPresentation = false
// When UISearchController presents the results view, present it in
// this view controller, not one further up the chain.
definesPresentationContext = true
}
}
// Handle the user's selection.
extension ViewController: GMSAutocompleteResultsViewControllerDelegate {
func resultsController(_ resultsController: GMSAutocompleteResultsViewController,
didAutocompleteWith place: GMSPlace) {
// Do something with the selected place.
print("Place name: \(place.name)")
print("Place address: \(String(describing: place.formattedAddress))")
print("Place attributions: \(String(describing: place.attributions))")
}
func resultsController(_ resultsController: GMSAutocompleteResultsViewController,
didFailAutocompleteWithError error: Error){
// TODO: handle the error.
print("Error: ", error.localizedDescription)
}
// Turn the network activity indicator on and off again.
func didRequestAutocompletePredictions(forResultsController resultsController: GMSAutocompleteResultsViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = true
}
func didUpdateAutocompletePredictions(forResultsController resultsController: GMSAutocompleteResultsViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = false
}
}
You just need to set the delegate to the controller, like this:
resultsViewController = GMSAutocompleteResultsViewController()
resultsViewController?.delegate = self
That should get rid of the warning.
Good luck!

How to search when search button clicked in keyboard?

I have a searchbar in my tableview header. For that i am using uisearchcontroler. But it update tablview data when i am texting in searchbar, i need to update tablview when search button in keyboard is clicked, because i get data for search in api and everytime when i am texting in searchbar it requesting and it takes long time. How i can resolve this?
var resultSearchController = UISearchController()
var indicator:UIActivityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)
var ref=UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
indicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
indicator.center = view.center
view.addSubview(indicator)
indicator.bringSubviewToFront(view)
indicator.startAnimating()
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
getRequests.getType1(tableView,spinner: indicator)
ref.addTarget(self, action: #selector(Catalog1TableViewController.refresh(_:)), forControlEvents: UIControlEvents.ValueChanged)
ref.attributedTitle = NSAttributedString(string: "Загрузка")
tableView.addSubview(ref)
}
func updateSearchResultsForSearchController(searchController: UISearchController)
{
indicator.startAnimating()
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
tableView.reloadData()
getRequests.getProduct(tableView, spinner: indicator,name: searchController.searchBar.text!)
for item in getRequests.product {
if item.productTitle.containsString(searchController.searchBar.text!){
filteredTableData.append(item)
}
}
tableView.reloadData()
}
Try to implement UISearchBar Delegate method :
func searchBarSearchButtonClicked(searchBar: UISearchBar)
You should implement something like this in your view controller.
var resultSearchController = UISearchController()
resultSearchController.searchBar.delegate = self
extension ViewController: UISearchBarDelegate {
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
print("search button click")
}
}

Creating a tableViewCell with a mapView

I'm creating a tableViewCell with a mapView inside. however i can't seem to add a annotation based on a location in the viewController containing the tableView. i've started by in the cellForRowAtIndex by setting cell.location = orgObject.coordinate after that i've added following code to my custom cell. However location variable keep returning nil. i guess this is because awakeForNib is called before cellForRowAtIndexPath is called? how do i solve this?
import UIKit
import MapKit
class MapTableViewCell: UITableViewCell, MKMapViewDelegate {
var location: CLLocation?
#IBOutlet var mapView: MKMapView?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
//MapView
mapView!.showsPointsOfInterest = true
if let mapView = self.mapView
{
mapView.delegate = self
}
let orgLocation = CLLocationCoordinate2DMake(location!.coordinate.latitude, location!.coordinate.longitude)
let dropPin = MKPointAnnotation()
dropPin.coordinate = orgLocation
mapView!.addAnnotation(dropPin)
self.mapView?.setRegion(MKCoordinateRegionMakeWithDistance(orgLocation, 500, 500), animated: true)
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialisation code
//MapView
mapView!.showsPointsOfInterest = true
if let mapView = self.mapView
{
mapView.delegate = self
}
}
Call cell.showLocation(location) from cellForRowAtIndexPath
func showLocation(location:CLLocation) {
let orgLocation = CLLocationCoordinate2DMake(location!.coordinate.latitude, location!.coordinate.longitude)
let dropPin = MKPointAnnotation()
dropPin.coordinate = orgLocation
mapView!.addAnnotation(dropPin)
self.mapView?.setRegion(MKCoordinateRegionMakeWithDistance(orgLocation, 500, 500), animated: true)
}

Resources