[英]How do I get a reference to ARCGISRuntime SystemLocationDataSource in .net Standard Library?
I have an .net Xamarin Map app using Ersi ARCGIS mapping that I created using a .net Standard class library for all my shared code, Xamarin forms. I have an .net Xamarin Map app using Ersi ARCGIS mapping that I created using a .net Standard class library for all my shared code, Xamarin forms. How do i get a reference to a SystemLocationDataSouce that is only available in the specific android or IOS project.
我如何获得对仅在特定 android 或 IOS 项目中可用的 SystemLocationDataSouce 的引用。
I found a solution.我找到了解决方案。 For Android you need to call CheckSelfPermission() and RequestPermissions() in your android activity.
对于 Android,您需要在 android 活动中调用 CheckSelfPermission() 和 RequestPermissions()。 You can do this in your library project like this.
您可以像这样在您的库项目中执行此操作。 Here I'm passing in a reference to my map control so I can set the location source property from Android.
在这里,我传递了对我的 map 控件的引用,因此我可以从 Android 设置位置源属性。 Examples of this can be found in Ersi ARCGIS sample code.
这方面的示例可以在 Ersi ARCGIS 示例代码中找到。
#if XAMARIN_ANDROID
// See implementation in MainActivity.cs in the Android platform project.
MainActivity.Instance.AskForLocationPermission(MyMapView);
#else
await MyMapView.LocationDisplay.DataSource.StartAsync();
MyMapView.LocationDisplay.IsEnabled = true;
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.