【问题标题】:GoogleAPI PanoView StreetView Bug -image not loading correctlyGoogleAPI PanoView StreetView 错误 - 图像未正确加载
【发布时间】:2016-09-04 16:50:28
【问题描述】:

我正在开发的 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。)?。

我已经将我的方案设置为 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
    }

}

【问题讨论】:

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


    【解决方案1】:

    我自己修好了。我只是简单地在方法上加了一个半径:

    moveNearCoordinate(坐标:CLLocationCoordinate2D,半径:Uint)

    //Inside my viewDidLoad on the 4th line
    panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: buildingLat!, longitude: buildingLon!), radius: 100)
    

    你可以玩半径,看看最适合你的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      • 2021-03-18
      相关资源
      最近更新 更多