Swift GMSMarker icon in the top left corner of the view

jampez77

Title is pretty self explanatory. I've tried calling it in viewDidLayoutSubviews() as suggested here but it's given me no joy.

Here is my code:

override func viewDidLoad() {
    super.viewDidLoad()

    locationManager.requestWhenInUseAuthorization()

    mapView.mapType = .normal
    mapView.settings.zoomGestures   = true
    mapView.settings.tiltGestures   = true
    mapView.settings.rotateGestures = true
    mapView?.isMyLocationEnabled = true
    locationManager.startUpdatingLocation()
    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
    locationManager.delegate = self


    // Do any additional setup after loading the view, typically from a nib.
}

override func viewDidAppear(_ animated: Bool) {
    if(locationManager.location != nil){
        centerMapOnLocation(location: locationManager.location!)
    }
}

func centerMapOnLocation(location: CLLocation)
{
    let camera = GMSCameraPosition.camera(withLatitude: locationManager.location!.coordinate.latitude, longitude: locationManager.location!.coordinate.longitude, zoom: zoom)
        mapView?.animate(to: camera)
}
jampez77

I've figured out a fix so I'm putting it here in case someone else has this issue.

I changed from using mapView?.animate to GMSCameraPosition.camera and it seems to be working fine.

func centerMapOnLocation(location: CLLocation)
{
    let target = CLLocationCoordinate2D(latitude: locationManager.location!.coordinate.latitude, longitude: locationManager.location!.coordinate.longitude)
    mapView.camera = GMSCameraPosition.camera(withTarget: target, zoom: zoom)
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

swift printing a view at top left corner of the page

Place Icon at Top Left Corner in Multiline EditText

Layout view is in top left corner in emulator

Corner radius only for top and bottom left corner of a view

User-icon at top left corner in Ubuntu 20.04

Java: Replacing the coffee cup icon in the top-left corner of the Window

How to put an Icon Button at the top left corner in android jetpack compose?

react native view over a view in top left corner?

Why is there a "plus" icon at the top right corner of my view?

round top left corner

SwiftUI. How to align root view to the left top corner?

Why is corner radius applied only to top left and right corner for a custom view?

Desktop in top left corner of monitor

ConstraintLayout views in top left corner

Accessing top left corner of `uitable`

Set border for view with an icon in the corner

Alien Invasion score is in the top left corner instead in the top right corner

Qt disable clicking on the left corner icon

Android: putting an icon in the top right corner of a collapsingToolbarLayout?

Set a close icon in the top right corner of an image

Position icon at the top right corner of a fieldset with legend

Slack icon not visible in top right corner in ubuntu

Position icon at the top right corner of a div

Put Font Awesome icon in top right corner

CAShapeLayer missing pixel in top-left corner

WPF Window top left corner not being transparent

Putting text in top left corner of matplotlib plot

Graph nodes pushed to top left corner of svg

Qt aligning the application to the top left corner on screen