您当前的位置:首页 >> 家居百科

认真⼀个⾼德地图的 iOS / Android MAUI 控件(上)

2025-05-10 12:18:32

所在之处在⽬标不宜⽤服务器端⾥⾯的,所以程基本型码完变为后,模板努的⽂件就并未⽤了。但有个以致于就是,因为并不需要揣⻉,所以⽣变为的不宜⽤服务器端的容量才会较⼤。

动态努和模板努往常是相反,程基本型码的时候是不才会揣⻉到⽬标不宜⽤服务器端⾥⾯的,所以⽣变为不宜⽤服务器端的密度较⼩,⽽且⼀个动态努可以对等给多个不宜⽤服务器端使⽤。但⽣变为不宜⽤服务器端是仰赖于动态努,这也造变为了常常才会出现动态努发觉不到的情况。

我们来封存⼀下⾼德比例尺基础的 SDK - AMapFoundationKit.framework

这⾥就值得注意了完全相同的头⽂件数据,模块数据,以及模板努。你可以清晰看到⾼德比例尺自带变为 Framrwork 的发挥作用。这也是我们对努方的交往,程基本型码好的⼆先取制代码,向皆暴露头⽂件给第三⽅合作Ubuntu使⽤。

通过 Sharpie ⼯极具⽣变为 C# 调至⽤的毗连⼝

Shapie 是⼀个⾮常好⽤的反转⼯极具,它⽀持在 macOS 下对 Objective-C 的努的转。通过 Sharpie 可以对努⽂件给出的头⽂件先取⾏反转完变为 C# 的默认。在 MAUI 创始 Shapie ⼯极具就已经假定 , 我常常就利⽤这个⼯极具想到反转。

因为这次⾼德比例尺的功能我⽤到 3D ,所以我才会对⾼德的 AMapFoundationKit.Framework 和MAMapKit.framework 两个 Framework 先取⾏默认反转。

▌ 反转 AMapFoundationKit.Framework

sharpiebind-frameworkAMapFoundationKit.framework-sdkiphoneos15.5

▌ 反转 MAMapKit.framework

sharpie bind -framework MAMapKit.framework -sdk iphoneos15.5

不足之处:MAMapKit.framework 仰赖于 AMapFoundationKit.framework ,所以要放在⼀个相同的⽬拍下。

这⾥⾯要注意,你并不需要内置好 Xcode ,建议内置到最新 ,并完全相同最属于自己 iOS SDK , 当然你也可以根据并不需要默认不同旧版本的 iOS SDK , 你可以通过⼀次是命令检视自然环境

sharpie xcode -sdks

通过命令⾏默认⽣变为的是两个⽂件是 StructsAndEnums.cs 和 ApiDefinitions.cs ,StructsAndEnums.cs 完全相同的是⼀些常量和逻辑系统型基本型,ApiDefinitions.cs 完全相同的是⼀些毗连⼝和⽅法 。

创始 MAUI 的 iOS 默认项⽬

这⾥创始并不需要注意,直到现在 Visual Studio 2022 的先前都并未完变为,直到现在⼤家⽤命令⾏创始,因为我们有两个项⽬,并不需要创始两个 Binding 的项⽬分别是针对于 AMapFoundationKit.Framework 的项⽬协作

dotnet new iosbinding -o iOS.AMap.Foundation

针对于 MAMapKit.framework 的项⽬协作

dotnet new iosbinding -o iOS.AMap.3D

⽣变为好后,并不需要把 AMapFoundationKit.framework 放先取 iOS.AMap.Foundation 的⽬拍下,MAMapKit.framework 放先取 iOS.AMap.3D ⽬拍下。并把⽣变为的 StructsAndEnums.cs 和 ApiDefinitions.cs 放先取完全相同⽬录。

项⽬所设调至整

1.在 Sharpie ⽣变为的⽬拍下 StructsAndEnum.cs ,⽽在协作的 Binding ⽬拍下是 ApiDefinition.cs , 要把它替换丢弃。所以要对 .csproj 项⽬先取⾏删减

2. 对 iOS.AMap.Foundation 先取⾏程基本型码

▌ 在 AMapFoundationKit.framework.csproj 增高对 Framework 的中有⽤

Framework True False

Kind :原⽣默认型基本型可以是 Framwork 也可以是 StaticLibary

ForceLoad :强于加载,选项 True

SmartLink :电脑链毗连

完变为的项⽬.csproj 所设为

net6.0-ios enable true true true false Framework True False

程基本型码 iOS.AMap.Foundation , 你才会实在奔溃,因为⾮常多的丢失数据。这是因为 Shapie 想到反转时,⼀些反转没法想到好造变为了的,这个时候你就并不需要⼀个⼀个先取⾏调至整

▌归类⼀下丢失数据

The type or namespace name 'VerifyAttribute' could not be found

这类数据时因为反转时候并未确认好特性,所以才会增高 VerifyAttribute 标识符,这个⼀般情形把这个标识符正文丢弃就可以了,如

staticclassCFunctions { // NSString * AMapEmptyStringIfNil (NSString *s); [ DllImport ( "短时Internal") ] // [Verify (PlatformInvoke)] staticexternNSString AMapEmptyStringIfNil( NSString s) ; // extern CLLocationCoordinate2D AMapCoordinateConvert (CLLocationCoordinate2D coordinate, AMapCoordinateType type); [ DllImport ( "短时Internal") ] // [Verify (PlatformInvoke)] staticexternCLLocationCoordinate2D AMapCoordinateConvert ( CLLocationCoordinate2D coordinate, AMapCoordinateType type) ; // extern BOOL AMapDataAvailableForCoordinate (CLLocationCoordinate2D coordinate); [ DllImport ( "短时Internal") ] // [Verify (PlatformInvoke)] staticexternboolAMapDataAvailableForCoordinate ( CLLocationCoordinate2D coordinate) ; } The type or namespace name 'AMapFoundationKit'

取名为三维空间或许,这个你并不需要为 StructsAndEnums.cs 和 ApiDefinitions.cs 增高取名为快捷键就可以了,你可以单独⽤ AMapFoundationKit ,也可以⾃⼰删减喜欢的名称 ,我这⾥⽤ iOS.AMap.Foundation 名称和项⽬完全相同

Duplicate 'Static' attribute

这个是因为 ApiDefinitions.cs 的 Constants 反复定义了,这个就并不需要原于归并为⼀个就可以了

Unsupported type for Fields: bool for 'iOS.AMap.Foundation.Constants _amapLocationOverseas'.e

型基本型不完全相同造变为了程基本型码不通过,这个时候我删减为

[Field ("_amapLocationOverseas", "短时Internal")] IntPtr _amapLocationOverseas { get; }

这由此可知你就可以程基本型码通过 iOS.AMap.Foundation

3.对 iOS.AMap.3D 先取⾏程基本型码

▌ 去丢弃对 iOS.AMap.Foundation的中有⽤

因为 MAMapKit.framework 仰赖于 AMapFoundationKit.framework , 所以 iOS.AMap.3D 是仰赖于iOS.AMap.Foundation

< ItemGroup> < ProjectReference Include= "..iOS.Amap.FoundationiOS.Amap.Foundation.csproj"/>

▌ 中有⼊ MAMapKit.framework

Framework True True GLKit OpenGLES UIKit Foundation CoreGraphics QuartzCore CoreLocation CoreTelephony SystemConfiguration Security AdSupport JaCore -lz -lstdc++ -lc++

这个和 AMapFoundationKit.framework 不⼀由此可知的, 并不需要去丢弃 Framework 程基本型码时并不需要仰赖的项, 以及⽤到的程基本型码⽅基本型 ,这个和你默认的 framework 有关, 我这⾥选项⾼德比例尺,所以按照它们的⽂定时要求想到了相关所设。

完变为的项⽬.csproj 所设为

< ProjectSdk= "Microsoft.NET.Sdk"> < PropertyGroup> < TargetFramework> net6.0-ios < RootNamespace> iOS.Amap._3D < Nullable> enable < ImplicitUsings> true < IsBindingProject> true < AllowUnsafeBlocks> true < NoBindingEmbedding> false < ItemGroup> < ObjcBindingApiDefinitionInclude= "ApiDefinitions.cs"/> < ObjcBindingCoreSourceInclude= "StructsAndEnums.cs"/> < ItemGroup> < NativeReferenceInclude= "MAMapKit.framework"> < Kind> Framework < ForceLoad> True < SmartLink> True < Frameworks> GLKit OpenGLES UIKit Foundation CoreGraphics QuartzCore CoreLocation CoreTelephony SystemConfiguration Security AdSupport JaCore < LinkerFlags> -lz -lstdc++ -lc++ < ItemGroup> < ProjectReference Include= "..iOS.Amap.FoundationiOS.Amap.Foundation.csproj"/>

程基本型码 iOS.AMap.3D,你才会⽐之前更是奔溃,这个时候你并不需要有⾜够的透⼼, 除了和之前约莫的丢失数据皆,还有⼀些属于自己状况,我这⾥列举⼀下

Type 'MAMapViewDelegate' already defines a member called 'MapView' with the same parameter types

造变为这个或许是因为⽅法首字了,这也是 Objective-C 单方面基本型语言和习惯语言不⼀由此可知的地⽅,所以你要针对这个想到重取名为

如这个

// @optional -(void)mapView:(MAMapView *)mapView didAnnotationViewTapped: (MAAnnotationView *)view; [Export ("mapView:didAnnotationViewTapped:")] void MapView (MAMapView mapView, MAAnnotationView view);

删减为

// @optional -(void)mapView:(MAMapView *)mapView didAnnotationViewTapped: (MAAnnotationView *)view; [Export ("mapView:didAnnotationViewTapped:")] void MapViewDidAnnotationViewTapped (MAMapView mapView, MAAnnotationView view);

The type or namespace name 'IMAOverlay' could not be found

这个是取名为丢失,在 ApiDefinitions.cs ⽂件中会你可以发觉到 MAOverlay

[Protocol] interface MAOverlay : IMAAnnotation { // @required -(CLLocationCoordinate2D)coordinate; [Abstract] [Export ("coordinate")] // [Verify (MethodToProperty)] CLLocationCoordinate2D Coordinate { get; } // @required -(MAMapRect)boundingMapRect; [Abstract] [Export ("boundingMapRect")] // [Verify (MethodToProperty)] MAMapRect BoundingMapRect { get; } }

所以把所有 IMAOverlay 替换为 MAOverlay 才可。

The type or namespace name 'AutoGeneratedName' could not be found

把 AutoGeneratedName 更改

Constant value '-1' cannot be converted to a 'ulong'

指定型基本型偏差 AllCorners = ~0x0 改为 AllCorners = 0x0

Do not know how to make a signature for CoreLocation.CLLocationCoordinate2D in parameter`coordinates'

C# 是并未codice_的,在 Sharpie 反转时丢失了

'MAMapView_UserLocation.HeadingFilter': cannot declare instance members in a static class // @property (nonatomic) CLLocationDegrees headingFilter; [Export ("headingFilter")] double HeadingFilter( { get; set; })

这个定义要换变为

// @property (nonatomic) CLLocationDegrees headingFilter; [Export ("headingFilter")] double HeadingFilter; Cannot convert type 'Foundation.NSObject' to 'nint' // @property (nonatomic, weak) id rendererDelegate; [NullAllowed, Export ("rendererDelegate", ArgumentSemantic.Weak)] NSObject WeakRendererDelegate { get; set; }

删减为

// @property (nonatomic, weak) id rendererDelegate; [NullAllowed, Export ("rendererDelegate", ArgumentSemantic.Weak)] IntPtr WeakRendererDelegate { get; set; }

或者排除是⼀个漫⻓的操作过程,但程基本型码变为功⼀刻于你才会⾮常惊讶,这由此可知我们就把 AMapFoundationKit.framework和 MAMapKit.framework 默认变为功了。

先前创始⼀个 .NET for iOS 项⽬正确性⼀下

极就其发挥作用特地到我的 GitHub Repo 下载 :

小结

原⽣努默认虽然⽐较多死板的事情,但是显然也是⼗分医治的,当你看到程基本型码通过的那⼀刻于,你就才会明⽩个中会的快乐。还有⼀点,很多⼈认为应用软件回转合作开发不并不需要平台的基础基本知识了,实际还是并不需要。特别在这种原⽣努的默认上,就并不需要你既才会 C# ⼜才会 Objective-C 。期望该例⼦能给各位有所很感兴趣。特地⼤家憧憬下⼀篇Android 原生努默认。

相关天然资源

通过 Microsoft Docs 了解到 MAUI : 通过 Microsoft Learn 深造 MAUI :

通过 Microsoft Docs 了解到 :

MAUI

通过 Microsoft Learn 深造 MAUI:

使⽤⾼德比例尺 SDK for iOS 特地访问:

了解到 iOS 原⽣努默认的内容,特地访问 : platform/macios/binding/?context=xamarin%2Fios

多谢你读完了本文~相信你一定有一些感想、观点、或许想要理解。爱戴在评论区里畅所欲言,憧憬听到你的“感觉”哦!

同时,喜欢的内容也不要忘丢弃转发给你的小朋友们,多谢你的默许!

瞩目Microsoft中会国MSDN

镇江看白癜风去什么医院好
甘肃男科医院哪家比较好
贵州男科去哪看
贵州男科检查多少钱
广东哪个医院做人流好
家用血糖仪怎么选
哪种家用血糖仪比较好
瑞特血糖仪和罗氏血糖仪哪个好
血糖仪哪个牌子的好
抑制胃酸反流的药物
标签:地图
相关阅读
友情链接