Xamarin.iOS我可以在我的iOS应用程序中使用PlacePicker

时间:2017-05-15 13:51:05

标签: xamarin.ios gmsplacepicker

我如何在我的项目中实现PlacePicker,因为我可以通过实现此代码在iOS native中实现

@IBAction func pickPlace(_ sender: UIButton) {
  let config = GMSPlacePickerConfig(viewport: nil)
  let placePicker = GMSPlacePicker(config: config)

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

    guard let place = place else {
      print("No place selected")
      return
    }

    print("Place name \(place.name)")
    print("Place address \(place.formattedAddress)")
    print("Place attributions \(place.attributions)")
  })
}

我怎么能在Xamarin.iOS中做同样的事情

首先我需要将nuget包含在我的项目中

第二如何实现相同的代码

1 个答案:

答案 0 :(得分:0)

首先按instruction获取google api密钥

第二次在"some_message": { "is_seen": true, "seen_timestamp": 1494912826602, }

中调用此方法
FinishedLaunching

第三,在string googleApiKey = YOUR_KEY_HERE; public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { ConfigureGoogleMaps(); } void ConfigureGoogleMaps() { PlacesClient.ProvideApiKey(googleApiKey); MapServices.ProvideAPIKey(googleApiKey); }

中添加此键
Info.plist

第四,要求用户允许使用其位置<key>LSApplicationQueriesSchemes</key> <array> <string>googlechromes</string> <string>comgooglemaps</string> </array>

Info.plist

现在我们打电话给 PlacePicker

<key>NSLocationWhenInUseUsageDescription</key>
<string>This application requires location services to work</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>This application requires location services to work</string>

如果您想知道本机外观中任何方法名称的等效内容 here