ios - GoogleAPI PanoView StreetView Bug - 图像加载不正确

标签 ios swift xcode google-api google-street-view

我正在开发的 iOS 应用程序中使用谷歌街景。我在 vc 中设置了一个 panoView,似乎当我输入某些美国地址时,我得到了一些但不是其他地址的全景图像。对于我没有得到图像的位置,我得到的是一个灰色的加载屏幕。我去普通的谷歌并输入相同的确切地址,谷歌显示图像确实存在。为什么它对某些地址不起作用但对其他地址却起作用?

这是我得到图像的地址:
253 周125 St, New York 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

有什么问题?

顺便说一句,我正在使用 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)

你可以玩转半径,看看什么最适合你

关于ios - GoogleAPI PanoView StreetView Bug - 图像加载不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39319282/

相关文章:

swift - 在 swift 中覆盖受限扩展方法的推荐方法,避免消息 "Ambiguous use of ' xxx'"

ios - 在 Swift 应用程序中将自定义 .dylib 放在哪里?

ios - StoryBoard - 代理抛出异常 iOS Swift

swift - 使用自定义按钮从 TableView 中删除一行 - Swift 3

iphone - 渲染大量点

ios - 自定义Swift中uitabbar溢出项的TableViewController

ios - 将多个查询结果添加到数组中

arrays - 我需要使用数组将数据从 UITableViewController 传递到 UIViewController

ios - 用图像突出显示 UITableViewCell

iphone - 在 iPhone 上存储数据的最佳方式是什么?