[英]First iOS App with MapBox SDK - Location is wrong
Just starting with Mapbox. 只是从Mapbox开始。 Signed up for an account. 注册一个帐户。 Created a new Access Token, and copied it. 创建一个新的访问令牌,并将其复制。
'Mapbox-iOS-SDK', '~> 3.7'
输入了'Mapbox-iOS-SDK', '~> 3.7'
MGLMapView
拖延UIView到情节MGLMapView
上,占据了整个屏幕的约束,将其类重置为MGLMapView
MGLMapboxAccessToken
to Info.plist with my Access Token as String value 将MGLMapboxAccessToken
添加到Info.plist中,并将我的访问令牌作为字符串值 On ViewController, I have the following code: 在ViewController上,我有以下代码:
import UIKit import Mapbox class ViewController: UIViewController { @IBOutlet weak var viewMapBox: MGLMapView! override func viewDidLoad() { super.viewDidLoad() // Eiffel Tower - just testing... viewMapBox.setCenter(CLLocationCoordinate2D(latitude: 48.858093, longitude: 2.294694), zoomLevel: 9, animated: true) } }
Then run the app on the iPhone 8 Plus simulator. 然后在iPhone 8 Plus模拟器上运行该应用程序。 When the app is viewable, it is centred on the Ghana / Togo border in Africa! 当该应用可见时,它位于非洲加纳/多哥边界的中心!
I have the following in the console: 我在控制台中有以下内容:
2018-01-25 09:43:24.320396+0000 MapBox1[35433:8131719] [INFO] {}[Database]: recovered 19 frames from WAL file /Users/user/Library/Developer/CoreSimulator/Devices/6885A008-D320-4905-9C6E-60BF0AD4FD10/data/Containers/Data/Application/E2D43F85-2D44-4ABC-9147-B3C85256BD96/Library/Caches/com.domain.MapBox1/Cache.db-wal (Code 283) 2018-01-25 09:43:24.898002+0000 MapBox1[35433:8131726] Task .<1> finished with error - code: -999 2018-01-25 09:43:24.910760+0000 MapBox1[35433:8131715] Task .<1> HTTP load failed (error code: -999 [1:89]) 2018-01-25 09:43:24.320396 + 0000 MapBox1 [35433:8131719] [INFO] {} [数据库]:从WAL文件/ Users / user / Library / Developer / CoreSimulator / Devices / 6885A008-D320-中恢复了19帧4905-9C6E-60BF0AD4FD10 /数据/容器/数据/应用程序/E2D43F85-2D44-4ABC-9147-B3C85256BD96/Library/Caches/com.domain.MapBox1/Cache.db-wal(Code 283)2018-01-25 09: 43:24.898002 + 0000 MapBox1 [35433:8131726]任务。<1>完成,出错-代码:-999 2018-01-25 09:43:24.910760 + 0000 MapBox1 [35433:8131715]任务。<1> HTTP加载失败(错误代码:-999 [1:89])
So this is the first actual steps to getting Mapbox to work. 因此,这是使Mapbox正常工作的第一步。 I cannot even follow any of the tutorials if this doesn't work. 如果这不起作用,我什至不能遵循任何教程。
Can anyone assist please? 有人可以帮忙吗? Thanks 谢谢
I was able to get it to work as expected by changing animated: true
to animated: false
. 通过将animated: true
更改为animated: false
,可以使其按预期工作。 If you would like to animate the transition, you can either call set the center coordinate in a later delegate method (such as mapViewDidFinishLoadingMap:
), or use an animation to change the map's camera . 如果您想为过渡设置动画,则可以在以后的委托方法(例如mapViewDidFinishLoadingMap:
调用设置中心坐标,或使用动画来更改地图的相机 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.