简体   繁体   English

如何在 .net 标准库中获取对 ARCGISRuntime SystemLocationDataSource 的引用?

[英]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.

相关问题 如何将 PCL 转换为 .Net 标准库 - How do I convert a PCL to a .Net Standard library 如何从Visual Studio 2017中的.NET Framework 4.5控制台应用程序引用.NET标准库? - How Do You Reference a .NET Standard Library from a .NET Framework 4.5 Console Application in Visual Studio 2017? 我可以从.NET标准库中引用共享项目吗? - Can I reference a Shared Project from a .NET Standard Library? 如何在 .Net 标准类库中引用 Microsoft.VisualBasic? - How to Reference Microsoft.VisualBasic in a .Net Standard Class Library? 如何从 Xamarin iOS 绑定项目引用 .NET 标准库? - How to reference a .NET standard library from a Xamarin iOS binding project? NET Standard 库可以引用另一个 NET Standard 库吗? - Can a NET Standard library reference another NET Standard library? Roslyn 编译 - 如何引用 .NET 标准 2.0 class 库 - Roslyn compilation - how to reference a .NET Standard 2.0 class library 如何添加WSDL web参考.NET标准库 - How add WSDL web reference to.NET Standard library 如何将 .NET 标准库更改为 .NET 框架库? - How can I change a .NET standard library to a .NET framework library? 如何从log4net为.NET Standard 2.0类库设置FileAppender记录器? - How do I setup a FileAppender logger from log4net for a .NET Standard 2.0 class library?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM