Google地图不显示实际地图

时间:2016-07-31 10:40:55

标签: swift xcode google-maps dictionary

我已将Google Maps API和SDK集成到我的应用程序中。虽然只是玩游戏并跟随谷歌的一些例子,我注意到除了实际的地图视图外,一切都有效。因此,当前位置和附近的地方功能齐全。我在网上搜索了一些答案,有些人说这可能是你的包ID不正确,但在我这里并非如此。

这是我的代码:

@IBAction func pickPlace(_ sender: AnyObject) {

    userLocation?.currentPlace(callback: { (placeLikelihoods, error) -> Void in
        guard error == nil else {
            print("Current Place error: \(error!.localizedDescription)")
            return
        }

        if let placeLikelihoods = placeLikelihoods {
            for likelihood in placeLikelihoods.likelihoods {
                let place = likelihood.place
                print("Current Place name \(place.name) at likelihood \(likelihood.likelihood)")
                print("Current Place address \(place.formattedAddress)")
                print("Current Place attributions \(place.attributions)")
                print("Current PlaceID \(place.placeID)")
            }
        }
    })

    let center = CLLocationCoordinate2DMake(51.5108396, -0.0922251)
    let northEast = CLLocationCoordinate2DMake(center.latitude + 0.001, center.longitude + 0.001)
    let southWest = CLLocationCoordinate2DMake(center.latitude - 0.001, center.longitude - 0.001)
    let viewport = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
    let config = GMSPlacePickerConfig(viewport: viewport)
    placePicker = GMSPlacePicker(config: config)

    placePicker?.pickPlace(callback: { (place: GMSPlace?, error: NSError?) -> Void in
        if let error = error {
            print("Pick Place error: \(error.localizedDescription)")
            return
        }

        if let place = place {
            print("Place name \(place.name)")
            print("Place address \(place.formattedAddress)")
            print("Place attributions \(place.attributions)")
        } else {
            print("No place selected")
        }
    })

}

感谢我能得到的所有帮助,提前谢谢!

0 个答案:

没有答案