0

How do I change the compass location on a google map view using swift?

Answers on Stack Overflow are absurdly outdated. Please help! I asked this question a while ago but no one answered. I'm exhausted, my attempts at a solution have all failed, and my self esteem is at an all time low.

Previous answers here:

How to change myLocationButton position from a GMSMapView?

Moving the google maps compass

My Attempt:

//move position on google compass
for object in mapView!.subviews {
    if object.theClassName == "GMSUISettingsView" {
        for view in object.subviews {
            if view.theClassName == "GMSx_QTMButton" {
                var frame = view.frame
                frame.origin.y = frame.origin.y - 110 // Move the button 110 up
                view.frame = frame
            }
        }
    }
}

extension:

extension NSObject {
    var theClassName: String {
        return NSStringFromClass(type(of: self))
    }
}
emrcftci
  • 3,355
  • 3
  • 21
  • 35
newswiftcoder
  • 111
  • 1
  • 11

2 Answers2

1

In stead of using that extension, there's already a way to get the class name returned as a string, please update to the following approach

  for object in mapView!.subviews {
        if String(describing: object.self) == "GMSUISettingsView" {
        ...

I hope this helps

Jim Tierney
  • 4,078
  • 3
  • 27
  • 48
0

Something like this?

for sub1 in gMapView.subviews {     
 if String(describing: type(of: sub1)) == "GMSUISettingsPaddingView" {
     for sub2 in sub1.subviews {
         if String(describing: type(of: sub2)) == "GMSUISettingsView" {
             for sub3 in sub2.subviews {
                 if String(describing: type(of: sub3)) == "GMSCompassButton"...