我正在开发的iOS应用程序中使用谷歌街景。我在vc中设置了一个panoView,似乎当我输入某些美国地址时,我得到了一些pano图像,但不是其他人。对于没有图像的位置,我得到一个灰色的加载屏幕。我去普通谷歌,输入相同的地址,谷歌显示确实存在一张图片。为什么对某些地址不起作用,但对其他地址却起作用?
这是一个地址,我得到了一个图像:
253 w. 125 St,纽约NY 10027 -坐标(纬度:40.809847,经度:-73.950378)
但是我得到一个灰色的加载屏幕地址:
150 W 225 St, Bronx NY 10463 -坐标(纬度:40.8754871,纬度:-73.9137233)
我得到一个调试器错误消息:
1.移动接近坐标(40.8754871,-73.9137233错误:操作无法完成。(com.google.maps。GMSPanoramaService错误0.)?.
我已经将我的Scheme设置为Schemes>Edit Scheme>Options>AllowLocationSimulation>DefaultLocation>New York, NY, USA
有什么问题吗?
Btw我使用Xcode 7.3.1
import UIKit
import GoogleMaps
class SearchController: UIViewController, GMSMapViewDelegate, GMSPanoramaViewDelegate {
@IBOutlet weak var viewStreet: UIView!
var panoView: GMSPanoramaView!
var buildingLat: CLLocationDegrees?
var buildingLon: CLLocationDegrees?
var panoramaID: String?
let placesClient = GMSPlacesClient()
func viewDidLoad() {
super.viewDidLoad()
panoView = GMSPanoramaView(frame: CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height))
panoView.delegate = self
panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: buildingLat!, longitude: buildingLon!))
viewStreet.addSubview(panoView)
viewStreet.sendSubviewToBack(panoView)
print("nlat: (buildingLat)nlon: (buildingLon)n")
}
// MARK: - GMSPanoramaViewDelegate
func panoramaView(view: GMSPanoramaView, error: NSError, onMoveNearCoordinate coordinate: CLLocationCoordinate2D) {
print("n1.Moving near coordinate ((coordinate.latitude),(coordinate.longitude) error: (error.localizedDescription)?n")
}
func panoramaView(view: GMSPanoramaView, error: NSError, onMoveToPanoramaID panoramaID: String) {
print("n2.Moving to PanoID (panoramaID) error: (error.localizedDescription)??n")
}
func panoramaView(view: GMSPanoramaView, didMoveToPanorama panorama: GMSPanorama?) {
print("n3.Moved to panoramaID: (panorama!.panoramaID) " +
"coordinates: ((panorama!.coordinate.latitude),(panorama!.coordinate.longitude))???n")
self.panoramaID = panorama!.panoramaID
}
}
我自己修好了。我只是在方法上添加了一个半径:
moveNearCoordinate(坐标:CLLocationCoordinate2D,半径:Uint)
//Inside my viewDidLoad on the 4th line
panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: buildingLat!, longitude: buildingLon!), radius: 100)
你可以选择最适合你的半径