如何利用迅速改变谷歌地图我的位置按钮的位置

问题描述 投票:15回答:3

my location button

我用我的项目谷歌地图我想表明我的位置按钮一点了,我应该怎么做,使用SWIFT

ios iphone google-maps google-maps-api-3 currentlocation
3个回答
35
投票

您可以更改MapControls的位置通过设置填充您的地图视图。

 let mapView = GMSMapView()

 mapView.isMyLocationEnabled = true
 mapView.settings.myLocationButton = true

 mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 50)

它会改变我的位置控制的填充。从底部50像素和右50px的

参阅下面的屏幕快照,从底部和右侧添加50像素的填充。

enter image description here


6
投票

萨勃拉曼尼亚一样,这个作品非常好:

mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)

这是完美的,如果你在你的应用程序的导航条。


2
投票

更新迅速4:只改变我的位置按钮的位置只

for object in self.mapView.subviews{
            if(object.theClassName == "GMSUISettingsPaddingView"){
                for view in object.subviews{
                    if(view.theClassName == "GMSUISettingsView"){
                        for btn in view.subviews{
                            if(btn.theClassName == "GMSx_QTMButton"){
                                var frame = btn.frame
                                frame.origin.y = frame.origin.y - 100
                                btn.frame = frame

                            }
                        }
                    }
                }
            }
        }

    public extension NSObject {
    public var theClassName: String {
        return NSStringFromClass(type(of: self))
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.