- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试获取用户当前位置以使用 google maps API 显示。数周以来我一直在为这个问题苦苦挣扎,当我在模拟器中更改位置时,代码运行但不会更新到当前位置。
我的代码在下面,在查看其他人的操作方式后,他们都有 mapView.myLocationEnabled = true,而对我来说,这会产生一个错误,提示“myLocationEnabled 已重命名为”isMylocationEnabled。我看到了一些最新的帖子(从 2 个月前开始)并且每个人都在使用 myLocationEnabled 似乎没有错误,为什么我得到这个?这可能是我当前位置未更新的原因吗?
import UIKit
import GoogleMaps
class FirstViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var mapView: GMSMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
mapView.settings.myLocationButton = true
mapView.settings.compassButton = true
}
override func viewDidAppear(_ animated: Bool) {
locationManager.requestWhenInUseAuthorization()
}
func locationManager(manager: CLLocationManager , didChangeAuthorizationStatus status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse {
locationManager.startUpdatingLocation()
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
}
}
func locationManager(manager: CLLocationManager ,didUpdateLocations locations: [CLLocation]) {
if let location = locations.first {
mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, viewingAngle: 0)
let marker = GMSMarker()
marker.title = "Current Location"
marker.map = mapView
locationManager.stopUpdatingLocation()
}
}
}
最佳答案
所以我终于解决了这个问题!基本上,我用 GoogleMaps 和 GooglePlaces 更新了我现有的 Podfile,然后更新了 pod 以确保所有框架都正常工作。然后我使用这段代码让我的当前位置工作
import UIKit
import GoogleMaps
class FirstViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var mapView: GMSMapView!
var locationManager = CLLocationManager()
var vwGMap = GMSMapView()
override func viewDidLoad() {
super.viewDidLoad()
let camera: GMSCameraPosition = GMSCameraPosition.camera(withLatitude: 22.300000, longitude: 70.783300, zoom: 10.0)
vwGMap = GMSMapView.map(withFrame: self.view.frame, camera: camera)
vwGMap.camera = camera
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
locationManager.distanceFilter = 500
locationManager.requestWhenInUseAuthorization()
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
self.view = vwGMap
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if (status == CLAuthorizationStatus.authorizedWhenInUse)
{
vwGMap.isMyLocationEnabled = true
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let newLocation = locations.last
vwGMap.camera = GMSCameraPosition.camera(withTarget: newLocation!.coordinate, zoom: 15.0)
vwGMap.settings.myLocationButton = true
self.view = self.vwGMap
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(newLocation!.coordinate.latitude, newLocation!.coordinate.longitude)
marker.map = self.vwGMap
}
关于ios - 使用 GoogleMaps 时,myLocationEnabled 在 swift 上更改为 isMyLocationEnabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40792362/
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界. 这篇CFSDN的博客文章详解dedecms后台编辑器将回车 改为 的方法由作者收集整理,如果你对
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 6 年前。 Improve th
不是将代码放在正文的头部或末尾(我把它放在正文的末尾),如果我将代码放在 JS 文件中而不是在 html 中它自己的脚本标记,是否可以? (我假设它像任何其他代码一样工作正常,但我问以防万一) 最佳答
我尝试执行从\e 命令编写的查询,但现在我无法执行任何查询,但可以在 PSQL 中执行命令。 现在我注意到这一点,我输入的命令现在在\e 中。 当我关闭\e(尝试运行它)时问题开始了。 最佳答案 ps
我有一个这样的字符串($ 字符总是被其他字符包围): a$b c$d e$f 我希望我的字符串方法在 $ 前面放置一个 \ 并删除换行符: a\$bc\$de\$f 我试过了,但它没有放入 \ 字符:
我需要使用 Java 构建一个 XML 文件。问题是我必须使用一些特殊字符,例如“ć”,然后在我的移动应用程序中读取它。 如果我手动更改 ć 就可以正常工作至 ć在我的 XML 文件中的记事
我有一个removeUser 页面,我在其中使用,然后使用submitForm() 函数进行错误处理。这段代码运行得非常好: export default function RemoveUserPag
我在数据库 “2048-05-21” 中有一个看起来像这样的日期 我只想得到年份,在这一年我只想得到两个后面的数字并将两个前面的数字更改为19 example: data : 2048-05-21 1
public class Venus1 { public static void main(String args[]) { int[]x={1,2,3};
我有以下 PHP 脚本,现在我需要在 JavaScript 中做同样的事情。 JavaScript 中是否有类似于 PHP 函数的函数,我已经搜索了好几天但找不到类似的东西?我想做的是计算某个单词在数
这个问题在这里已经有了答案: Is it bad practice to specify an array size using a variable instead of `#define` in
我陷入了一种情况,我必须通过“选中”工具栏中的复选框来“选中”列表中存在的所有复选框。 这是创建复选框列表的代码:- itemTpl: 'checked="checked" /> {groupName
我正在使用Python3。在分析一些网站时,我遇到了一些奇怪的字符并寻找解决方案。我找到了一个,但在找到解决方案之前,我尝试了一些方法,并且知道我无法重置它。当我使用 Jupyter 笔记本将列表 l
我在 http 下有 unity android app 和 site api 的工作基础设施。 最近换了服务器,申请了ssl证书。现在我的 api 在 https 下。 在 unity 应用程序中,
我在 http 下有 unity android app 和 site api 的工作基础设施。 最近换了服务器,申请了ssl证书。现在我的 api 在 https 下。 在 unity 应用程序中,
我在 Objective-C 中有一些代码。我想,我收到了 NSString 类型,但是当我尝试将它保存在核心数据中时,我得到了一个 user.clientID = clientID; 错误,例如:
在表中我有一个名为 CallTime 的字段 (Varchar)。 包括晚上8:00、晚上8:40、上午10:00等时间 我想将字段类型更改为“时间”并更新时间格式。该怎么做? 谢谢 最佳答案 UPD
这个问题在这里已经有了答案: C# - for Loop Freezes at strange intervals (3 个答案) 关闭 6 年前。 我试图解决 problem #14 from P
我今天在 Pycharm 社区版 5.0.3 中收到了这个错误,想知道这是否只是我做错了/没有意识到,或者是 PyCharm lint 问题。重现错误的代码是 mylist = list() # fi
我的目标是将数据库中的随机文本显示到网页上。首先,我不知道为什么我的数据没有保存,为什么我得到的是[Entity of type sec.helloweb.HelloMessage with id:
我是一名优秀的程序员,十分优秀!