فهرست منبع

fix:完善高德地图设置。

“HeShaoZe” 8 ماه پیش
والد
کامیت
95376d578d
27فایلهای تغییر یافته به همراه519 افزوده شده و 70 حذف شده
  1. BIN
      ios/.symlinks/plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_uparrow.png
  2. 1 1
      ios/Podfile.lock
  3. 2 0
      ios/Runner/Info.plist
  4. 27 0
      ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/build-request.json
  5. BIN
      ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/description.msgpack
  6. 1 0
      ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/manifest.json
  7. 1 0
      ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/target-graph.txt
  8. BIN
      ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/task-store.msgpack
  9. 11 0
      plugins/map_amap_ios/ios/Classes/ExtensionTool/MACoordinateRegion+HandleTool.swift
  10. 14 16
      plugins/map_amap_ios/ios/Classes/ExtensionTool/MKMapView+HandleTool.swift
  11. 1 0
      plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapArrowPolyRenderer.swift
  12. 12 18
      plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapMarkerNormalView.swift
  13. 1 1
      plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapMarkerPictureView.swift
  14. 14 8
      plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapMarkerWriterCenterView.swift
  15. 12 9
      plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapPopUpWindowView.swift
  16. 414 17
      plugins/map_amap_ios/ios/Classes/MapAmapContentView/MapAmapThemeControl.swift
  17. 3 0
      plugins/map_amap_ios/ios/Classes/MapAmapIosPlugin.swift
  18. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_friend.png
  19. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_location_error.png
  20. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_map_pin.png
  21. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_mine.png
  22. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_mine_selected.png
  23. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_traceEndFriend.png
  24. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_traceEndMine.png
  25. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_traceStart.png
  26. BIN
      plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_uparrow.png
  27. 5 0
      plugins/map_amap_ios/ios/map_amap_ios.podspec

BIN
ios/.symlinks/plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_uparrow.png


+ 1 - 1
ios/Podfile.lock

@@ -175,7 +175,7 @@ SPEC CHECKSUMS:
   gravity_engine: 9075091c4adcd0169506f97688ebac7f5454c4ac
   in_app_purchase_storekit: d1a48cb0f8b29dbf5f85f782f5dd79b21b90a5e6
   in_app_review: 5596fe56fab799e8edb3561c03d053363ab13457
-  map_amap_ios: 83f8a3ca9376a988e3dd7b17bb85ce35b83adb78
+  map_amap_ios: 15cdf8a7c32fc8f366792c37a5200e540677d44f
   MMKV: b4802ebd5a7c68fc0c4a5ccb4926fbdfb62d68e0
   mmkv_ios: b1c2c12115c0ff971534015f61aea8de18d8d126
   MMKVCore: a255341a3746955f50da2ad9121b18cb2b346e61

+ 2 - 0
ios/Runner/Info.plist

@@ -59,6 +59,8 @@
 	<string>为给您更精准的提供个性化内容,请您允许我们获取广告信息</string>
     <key>NSUserNotificationUsageDescription</key>
     <string>通知可能包括提醒,声音和图标标记。可在“设置”中配置相关功能</string>
+    <key>AMapApiKey</key>
+    <string>ed76ac32e33f33d7724936e9efbc2cd2</string>
 	<key>UIApplicationSupportsIndirectInputEvents</key>
 	<true/>
 	<key>UIBackgroundModes</key>

+ 27 - 0
ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/build-request.json

@@ -0,0 +1,27 @@
+{
+  "buildCommand" : {
+    "command" : "build",
+    "skipDependencies" : false,
+    "style" : "buildOnly"
+  },
+  "configuredTargets" : [
+
+  ],
+  "continueBuildingAfterErrors" : false,
+  "dependencyScope" : "workspace",
+  "enableIndexBuildArena" : false,
+  "hideShellScriptEnvironment" : false,
+  "parameters" : {
+    "action" : "build",
+    "overrides" : {
+
+    }
+  },
+  "qos" : "utility",
+  "schemeCommand" : "launch",
+  "showNonLoggedProgress" : true,
+  "useDryRun" : false,
+  "useImplicitDependencies" : false,
+  "useLegacyBuildLocations" : false,
+  "useParallelTargets" : true
+}

BIN
ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/description.msgpack


+ 1 - 0
ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/manifest.json

@@ -0,0 +1 @@
+{"client":{"name":"basic","version":0,"file-system":"device-agnostic","perform-ownership-analysis":"no"},"targets":{"":["<all>"]},"commands":{"<all>":{"tool":"phony","inputs":["<WorkspaceHeaderMapVFSFilesWritten>"],"outputs":["<all>"]},"P0:::Gate WorkspaceHeaderMapVFSFilesWritten":{"tool":"phony","inputs":[],"outputs":["<WorkspaceHeaderMapVFSFilesWritten>"]}}}

+ 1 - 0
ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/target-graph.txt

@@ -0,0 +1 @@
+Target dependency graph (0 target)

BIN
ios/build/XCBuildData/7331614de4987641e39634aa4cb7a827.xcbuilddata/task-store.msgpack


+ 11 - 0
plugins/map_amap_ios/ios/Classes/ExtensionTool/MACoordinateRegion+HandleTool.swift

@@ -0,0 +1,11 @@
+//
+//  MACoordinateRegion+HandleTool.swift
+//  map_amap_ios
+//
+//  Created by 诺诺诺的言 on 2025/7/23.
+//
+
+import Foundation
+import MapKit
+import AMapFoundationKit
+

+ 14 - 16
plugins/map_amap_ios/ios/Classes/ExtensionTool/MKMapView+HandleTool.swift

@@ -7,25 +7,26 @@
 
 import Foundation
 import MapKit
+import MAMapKit
 
-extension MKMapView {
+extension MAMapView {
     // 按比例 按padding适应annotation
-    public func fitsAllPoints(
-        points: [MKMapPoint],
+    /*public func fitsAllPoints(
+        points: [MAMapPoint],
         padding: UIEdgeInsets,
         aspectRatio: Double? = nil,
         animated: Bool = true
     ) {
-        var zoomRect: MKMapRect = .null
+        var zoomRect: MAMapRect = MAMapRect()
         for point in points {
-            let pointRect = MKMapRect(x: point.x, y: point.y, width: 0, height: 0)
-            if zoomRect.isNull {
+            let pointRect = MAMapRectMake(point.x, point.y, 0, 0)//MAMapRect(x: point.x, y: point.y, width: 0, height: 0)
+            if zoomRectt {
                 zoomRect = pointRect
             } else {
                 zoomRect = zoomRect.union(pointRect)
             }
         }
-
+        
         // Calculate the desired size based on the aspect ratio
         let aspectRatio = aspectRatio ?? 1.0
         let width = zoomRect.size.width
@@ -57,7 +58,7 @@ extension MKMapView {
             }
         }
         return mapRectThatFits(zoomRect, edgePadding: padding)
-    }
+    }*/
 
     func takeSnapShot(option: MKMapSnapshotter.Options, completion: @escaping (MKMapSnapshotter.Snapshot?) -> Void) {
         let shotter = MKMapSnapshotter(options: option)
@@ -101,11 +102,11 @@ extension MKMapView {
         let safeSpanLng = max(min(spanLng, 100.0), 0.001)
         
         // 创建初始区域
-        let span = MKCoordinateSpan(latitudeDelta: safeSpanLat, longitudeDelta: safeSpanLng)
+        let span = MACoordinateSpan(latitudeDelta: safeSpanLat, longitudeDelta: safeSpanLng)
         print("初始区域: center=\(center), span=\(span)")
         
         // 3. 创建区域并应用padding
-        var region = MKCoordinateRegion(center: center, span: span)
+        var region = MACoordinateRegion(center: center, span: span)//MKCoordinateRegion(center: center, span: span)
         
         // 应用padding(如果有)
         if let padding = padding {
@@ -137,7 +138,7 @@ extension MKMapView {
     }
 
     // 辅助方法:检查区域是否有效
-    private func isValidRegion(_ region: MKCoordinateRegion) -> Bool {
+    private func isValidRegion(_ region: MACoordinateRegion) -> Bool {
         let center = region.center
         let span = region.span
         
@@ -150,11 +151,8 @@ extension MKMapView {
     }
 
     // 辅助方法:提供默认有效区域
-    private func defaultRegion() -> MKCoordinateRegion {
-        return MKCoordinateRegion(
-            center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
-            span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
-        )
+    private func defaultRegion() -> MACoordinateRegion {
+        return MACoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194), span: MACoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1))
     }
 
     // 辅助方法:检查坐标是否有效

+ 1 - 0
plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapArrowPolyRenderer.swift

@@ -0,0 +1 @@
+

+ 12 - 18
plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapMarkerNormalView.swift

@@ -6,9 +6,10 @@
 //
 
 import Foundation
-import MapKit
+import MAMapKit
+//import MapKit
 
-class MapAnnotationView: MKAnnotationView {
+class MapAnnotationView: MAPinAnnotationView {
     
     static let identifier: String = "MapAnnotationView"
 
@@ -28,12 +29,20 @@ class MapAnnotationView: MKAnnotationView {
         return (marker?.isSelected ?? false) || self.isSelected
     }
     
-    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
+    override init!(annotation: (any MAAnnotation)!, reuseIdentifier: String!) {
         super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
         self.marker = annotation as? ATMapMarker
         self.isEnabled = marker?.markerType.supportSelected ?? false
         self.isHidden = false
     }
+    
+    
+//    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
+//        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
+//        self.marker = annotation as? ATMapMarker
+//        self.isEnabled = marker?.markerType.supportSelected ?? false
+//        self.isHidden = false
+//    }
 
     required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
@@ -193,21 +202,6 @@ class MapAnnotationView: MKAnnotationView {
             centerOffset = CGPoint(x: 0, y: -markerSize.height/2)
         }
     }
-    
-    override func prepareForDisplay() {
-        super.prepareForDisplay()
-        // 确保视图已经设置好
-        if markerImageView == nil {
-            updateView()
-        }
-        // 更新选中状态
-        guard let marker = marker,
-              let url = marker.customAvatarUrl,
-              !url.isEmpty else {
-            markerImageView?.isSelected = annotationSelected
-            return
-        }
-    }
 
     override func setSelected(_ selected: Bool, animated: Bool) {
         super.setSelected(selected, animated: animated)

+ 1 - 1
plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapMarkerPictureView.swift

@@ -56,7 +56,7 @@ class MapAmapMarkerPictureView: UIView {
         }
         
         // 尝试从插件资源束加载
-        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_mapkit_ios_resources", withExtension: "bundle")
+        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_amap_ios_image_source", withExtension: "bundle")
         if let bundleURL = bundleURL, let resourceBundle = Bundle(url: bundleURL) {
             return UIImage(named: imageName, in: resourceBundle, compatibleWith: nil)
         }

+ 14 - 8
plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapMarkerWriterCenterView.swift

@@ -6,9 +6,10 @@
 //
 
 import Foundation
-import MapKit
+//import MapKit
+import MAMapKit
 
-class MapAnnotationAnchorPointView: MKAnnotationView {
+class MapAnnotationAnchorPointView: MAPinAnnotationView {
     
     static let identifier: String = "MapAnnotationAnchorPointView"
 
@@ -20,14 +21,18 @@ class MapAnnotationAnchorPointView: MKAnnotationView {
 
     var centerContentView: UIView?
     
-
-    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
+    override init!(annotation: (any MAAnnotation)!, reuseIdentifier: String!) {
         super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
-        self.backgroundColor = UIColor.purple
         self.marker = annotation as? ATMapMarker
-//        self.isEnabled = marker?.markerType.supportSelected ?? false
-//        self.isHidden = false
     }
+    
+//    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
+//        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
+//        self.backgroundColor = UIColor.purple
+//        self.marker = annotation as? ATMapMarker
+////        self.isEnabled = marker?.markerType.supportSelected ?? false
+////        self.isHidden = false
+//    }
 
     required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
@@ -96,7 +101,8 @@ class MapAnnotationAnchorPointView: MKAnnotationView {
         }
         
         // 尝试从插件资源束加载
-        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_mapkit_ios_resources", withExtension: "bundle")
+        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_amap_ios_image_source", withExtension: "bundle")
+        print("bundleURLsfsfdsdf-----\(bundleURL)")
         if let bundleURL = bundleURL, let resourceBundle = Bundle(url: bundleURL) {
             return UIImage(named: imageName, in: resourceBundle, compatibleWith: nil) ?? UIImage()
         }

+ 12 - 9
plugins/map_amap_ios/ios/Classes/IndividualToolView/MapAmapPopUpWindowView.swift

@@ -6,10 +6,11 @@
 //
 
 import Foundation
-import MapKit
+//import MapKit
+import MAMapKit
 
 
-class MapAmapPopUpWindowView : MKAnnotationView {
+class MapAmapPopUpWindowView : MAPinAnnotationView {
     
     static let identifier: String = "MapAnotationBubbleView"
 
@@ -37,12 +38,19 @@ class MapAmapPopUpWindowView : MKAnnotationView {
         return (marker?.isSelected ?? false) || self.isSelected
     }
     
-    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
+    override init!(annotation: (any MAAnnotation)!, reuseIdentifier: String!) {
         super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
         self.marker = annotation as? ATMapMarker
         self.isEnabled = marker?.markerType.supportSelected ?? false
         self.isHidden = false
     }
+    
+    /*override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
+        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
+        self.marker = annotation as? ATMapMarker
+        self.isEnabled = marker?.markerType.supportSelected ?? false
+        self.isHidden = false
+    }*/
 
     required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
@@ -200,7 +208,7 @@ class MapAmapPopUpWindowView : MKAnnotationView {
         }
         
         // 尝试从插件资源束加载
-        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_mapkit_ios_resources", withExtension: "bundle")
+        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_amap_ios_image_source", withExtension: "bundle")
         if let bundleURL = bundleURL, let resourceBundle = Bundle(url: bundleURL) {
             return UIImage(named: imageName, in: resourceBundle, compatibleWith: nil) ?? UIImage()
         }
@@ -217,11 +225,6 @@ class MapAmapPopUpWindowView : MKAnnotationView {
         // 没有文本时,仅需要将图片底部对准坐标点
         centerOffset = CGPoint(x: 0, y: -markerSize.height/2)
     }
-    
-    override func prepareForDisplay() {
-        super.prepareForDisplay()
-        // 确保视图已经设置好
-    }
 
     override func setSelected(_ selected: Bool, animated: Bool) {
         super.setSelected(selected, animated: animated)

+ 414 - 17
plugins/map_amap_ios/ios/Classes/MapAmapContentView/MapAmapThemeControl.swift

@@ -6,7 +6,7 @@
 //
 
 import Foundation
-//import MapKit
+import MapKit
 import Combine
 import AMapFoundationKit
 import MAMapKit
@@ -33,24 +33,39 @@ class MapAmapThemeControl: UIViewController {
 
     override func viewDidLoad() {
         super.viewDidLoad()
+        // 1. 设置隐私(必须!)
+        MAMapView.updatePrivacyShow(.didShow, privacyInfo: .didContain)
+        MAMapView.updatePrivacyAgree(.didAgree)
+        
         AMapServices.shared().enableHTTPS = true
         loadMainMapView()
         bindViewModel()
     }
 
     private func loadMainMapView() {
-        autonaviMap = MAMapView()
-        autonaviMap.delegate = self
-        autonaviMap.mapType = .standard
-        autonaviMap.showsUserLocation = false
-        autonaviMap.userTrackingMode = .follow
-        autonaviMap.translatesAutoresizingMaskIntoConstraints = false
-        view.addSubview(autonaviMap)
+        guard AMapServices.shared().apiKey != nil else {
+            fatalError("高德地图API Key未配置!")
+        }
+        
+        autonaviMap = MAMapView(frame: view.bounds)
+        print("地图初始化失败,请检查Key和Bundle ID--\(autonaviMap)")
+        guard let map = autonaviMap else {
+            print("地图初始化失败,请检查Key和Bundle ID--")
+            return
+        }
+        
+        map.delegate = self
+        map.mapType = .standard
+        map.showsUserLocation = false
+        map.userTrackingMode = .follow
+        view.addSubview(map)
+        map.translatesAutoresizingMaskIntoConstraints = false
+        view.addSubview(map)
         NSLayoutConstraint.activate([
-            autonaviMap.topAnchor.constraint(equalTo: view.topAnchor),
-            autonaviMap.bottomAnchor.constraint(equalTo: view.bottomAnchor),
-            autonaviMap.leadingAnchor.constraint(equalTo: view.leadingAnchor),
-            autonaviMap.trailingAnchor.constraint(equalTo: view.trailingAnchor)
+            map.topAnchor.constraint(equalTo: view.topAnchor),
+            map.bottomAnchor.constraint(equalTo: view.bottomAnchor),
+            map.leadingAnchor.constraint(equalTo: view.leadingAnchor),
+            map.trailingAnchor.constraint(equalTo: view.trailingAnchor)
         ])
     }
     
@@ -58,6 +73,280 @@ class MapAmapThemeControl: UIViewController {
         viewModel.$markers
             .receive(on: DispatchQueue.main)
             .sink { [weak self] markers in
+                if let annotationsList = self?.autonaviMap.annotations {
+                    print("annotationsListsdfsdfs---\(annotationsList)");
+                    self?.autonaviMap.removeAnnotations(self?.autonaviMap.annotations)
+                }
+//                UIView.animate(withDuration: 0.3) {
+//                    self?.autonaviMap.addAnnotations(markers)
+//                }
+                
+                
+                var mapMarkerList = [MAPointAnnotation]();
+                for markerItem in markers {
+                    let annotationItem : MyMAPointAnnotation = MyMAPointAnnotation(itemMarker: markerItem)
+                    annotationItem.title = markerItem.markerName;
+                    annotationItem.coordinate = markerItem.coordinate;
+                    mapMarkerList.append(annotationItem)
+                }
+                self?.autonaviMap.addAnnotations(mapMarkerList)
+               // self?.autonaviMap.selectAnnotation(mapMarkerList.first, animated: true)
+                self?.autonaviMap.setZoomLevel(20, animated: true)
+                if !mapMarkerList.isEmpty {
+                    let selectIemt : MAPointAnnotation = mapMarkerList.first!
+                    self?.autonaviMap.setCenter(selectIemt.coordinate, animated: true)
+                }
+
+                //self?.mapView.removeAnnotations(self?.mapView.annotations ?? [])
+//                UIView.animate(withDuration: 0.3) {
+//                    self?.mapView.addAnnotations(markers)
+//                }
+            }
+            .store(in: &cancellables)
+        
+        
+        
+        viewModel.$polylines
+            .receive(on: DispatchQueue.main)
+            .sink { [weak self] polylines in
+                
+                
+                guard let self, !polylines.isEmpty else { return }
+                // 清除旧覆盖物
+                self.autonaviMap.removeOverlays(self.autonaviMap.overlays)
+                
+                var polyinesList = [MAPolyline]();
+                for polyline in polylines {
+                    let polylineItem : MyMAPolyline = MyMAPolyline(coordinates: &polyline.points, count: UInt(polyline.points.count))
+                    polylineItem.itemPolyLine = polyline
+                    polyinesList.append(polylineItem)
+                }
+                
+                // 添加新覆盖物
+                self.autonaviMap.addOverlays(polyinesList)
+                
+                // 自动调整视野
+                if let lastPolyline = polylines.last,
+                   let padding = lastPolyline.mapPadding {
+                    self.autonaviMap.showOverlays(
+                        polyinesList,
+                        edgePadding: UIEdgeInsets(
+                            top: padding.top,
+                            left: padding.left,
+                            bottom: padding.bottom,
+                            right: padding.right
+                        ),
+                        animated: true
+                    )
+                }
+                
+                /*var polyinesList = [MKPolyline]();
+                for polyline in polylines {
+                    let polylineItem : MKPolyline = polyline.polyline
+                    polylineItem.associatedLineId = polyline.id
+                    polylineItem.associatedLineType = polyline.lineType
+                    polylineItem.associatedColor = polyline.color
+                    polylineItem.associatedWidth = polyline.width
+                    polyinesList.append(polylineItem)
+                }
+                self?.mapView.addOverlays(polyinesList)
+                //self?.mapView.addOverlays(polylines.map({ $0.polyline }))
+                if let padding = polylines.last?.mapPadding {
+                    self?.mapView.fitsAllPoints(
+                        points: polylines.last?.points.compactMap({ MKMapPoint($0) }) ?? [],
+                        padding: padding.padding,
+                        animated: true
+                    )
+                }
+                
+                
+                guard let self, !polylines.isEmpty else { return }
+                
+                // 清除旧覆盖物
+                self.autonaviMap.removeOverlays(self.autonaviMap.overlays)
+                
+                // 创建自定义Polyline类数组
+                let customPolylines = polylines.compactMap { polyline -> CustomPolyline? in
+                    // 创建高德地图Polyline
+                    let count = UInt(polyline.points.count)
+                    
+                    guard let mapPolyline = MAPolyline(coordinates:  &polyline.points , count: count) else {
+                        return nil
+                    }
+            
+                    // 使用自定义类包装
+                    return CustomPolyline(
+                        polyline: mapPolyline,
+                        id: polyline.id,
+                        color: polyline.color,
+                        width: polyline.width
+                    )
+                }
+                
+                // 添加新覆盖物
+                self.autonaviMap.addOverlays(customPolylines.map { $0.polyline })
+                
+                // 自动调整视野
+                if let lastPolyline = polylines.last,
+                   let padding = lastPolyline.mapPadding {
+                    self.autonaviMap.showOverlays(
+                        customPolylines.map { $0.polyline },
+                        edgePadding: UIEdgeInsets(
+                            top: padding.top,
+                            left: padding.left,
+                            bottom: padding.bottom,
+                            right: padding.right
+                        ),
+                        animated: true
+                    )
+                }*/
+            }
+            .store(in: &cancellables)
+        
+        //移动至多个点的位置,并提供设置padding距离
+        viewModel.$suitableLocation
+            .receive(on: DispatchQueue.main)
+            .sink{ [weak self] polylines in
+                if let padding = polylines.last?.mapPadding {
+                    if let atMapPoint : [CLLocationCoordinate2D] = polylines.last?.points {
+                        self?.autonaviMap.moveToSuitableLocation(points: atMapPoint, padding: padding)
+                        //self?.mapView.moveToSuitableLocation(points: atMapPoint, padding: padding)
+                    }
+                }
+            }
+            .store(in: &cancellables)
+        
+        /*viewModel.$polylines
+            .receive(on: DispatchQueue.main)
+            .sink { [weak self] polylines in
+                guard let self else { return }
+                
+                // 清除旧覆盖物
+                self.autonaviMap.removeOverlays(self.autonaviMap.overlays)
+                
+                // 空数据检查
+                guard !polylines.isEmpty else {
+                    print("轨迹数据为空")
+                    return
+                }
+                
+                // 处理每条轨迹
+                var validPolylines: [MAPolyline] = []
+                
+                for polyline in polylines {
+                    // 坐标数量检查
+                    guard !polyline.points.isEmpty else {
+                        print("发现空坐标的轨迹: \(polyline.id)")
+                        continue
+                    }
+                    
+                    // 指针转换
+                    let creationResult = polyline.points.withUnsafeBufferPointer { bufferPointer -> MAPolyline? in
+                        guard let baseAddress = bufferPointer.baseAddress, bufferPointer.count > 0 else {
+                            return nil
+                        }
+                        
+                        let unsafePointer = UnsafeMutablePointer(mutating: baseAddress)
+                        return MAPolyline(
+                            coordinates: unsafePointer,
+                            count: UInt(bufferPointer.count)
+                        )
+                    }
+                    
+                    // 结果检查
+                    guard let mapPolyline = creationResult else {
+                        print("轨迹创建失败: \(polyline.id)")
+                        continue
+                    }
+                    
+                    // 绑定属性
+                    mapPolyline.associatedData = [
+                        "id": polyline.id,
+                        "color": polyline.color,
+                        "width": polyline.width
+                    ]
+                    
+                    validPolylines.append(mapPolyline)
+                }
+                
+                // 添加有效轨迹
+                guard !validPolylines.isEmpty else {
+                    print("没有有效的轨迹数据")
+                    return
+                }
+                
+                self.autonaviMap.addOverlays(validPolylines)
+                
+                // 调整视野
+                if let lastValid = validPolylines.last,
+                   let padding = polylines.last?.mapPadding {
+                    self.autonaviMap.showOverlays(
+                        validPolylines,
+                        edgePadding: UIEdgeInsets(
+                            top: padding.top,
+                            left: padding.left,
+                            bottom: padding.bottom,
+                            right: padding.right
+                        ),
+                        animated: true
+                    )
+                }
+            }
+            .store(in: &cancellables)
+        
+        viewModel.$markers
+            .receive(on: DispatchQueue.main)
+            .sink { [weak self] markers in
+                self?.mapView.removeAnnotations(self?.mapView.annotations ?? [])
+                UIView.animate(withDuration: 0.3) {
+                    self?.mapView.addAnnotations(markers)
+                }
+            }
+            .store(in: &cancellables)
+
+        viewModel.$polylines
+            .receive(on: DispatchQueue.main)
+            .sink { [weak self] polylines in
+                self?.mapView.removeOverlays(self?.mapView.overlays ?? [])
+                var polyinesList = [MKPolyline]();
+                for polyline in polylines {
+                    let polylineItem : MKPolyline = polyline.polyline
+                    polylineItem.associatedLineId = polyline.id
+                    polylineItem.associatedLineType = polyline.lineType
+                    polylineItem.associatedColor = polyline.color
+                    polylineItem.associatedWidth = polyline.width
+                    polyinesList.append(polylineItem)
+                }
+                self?.mapView.addOverlays(polyinesList)
+                //self?.mapView.addOverlays(polylines.map({ $0.polyline }))
+                if let padding = polylines.last?.mapPadding {
+                    self?.mapView.fitsAllPoints(
+                        points: polylines.last?.points.compactMap({ MKMapPoint($0) }) ?? [],
+                        padding: padding.padding,
+                        animated: true
+                    )
+                }
+            }
+            .store(in: &cancellables)
+        
+        //移动至多个点的位置,并提供设置padding距离
+        viewModel.$suitableLocation
+            .receive(on: DispatchQueue.main)
+            .sink{ [weak self] polylines in
+                if let padding = polylines.last?.mapPadding {
+                    if let atMapPoint : [CLLocationCoordinate2D] = polylines.last?.points {
+                        self?.mapView.moveToSuitableLocation(points: atMapPoint, padding: padding)
+                    }
+                }
+            }
+            .store(in: &cancellables)*/
+    }
+    
+    
+    /*private func bindViewModel() {
+        viewModel.$markers
+            .receive(on: DispatchQueue.main)
+            .sink { [weak self] markers in
                 self?.autonaviMap.removeAnnotations(self?.autonaviMap.annotations)
                 var mapMarkerList = [MAPointAnnotation]();
                 for markerItem in markers {
@@ -79,7 +368,7 @@ class MapAmapThemeControl: UIViewController {
             }
             .store(in: &cancellables)
         
-        /*viewModel.$currentRegion
+        viewModel.$currentRegion
             .compactMap { $0 }
             .receive(on: DispatchQueue.main)
             .sink { [weak self] region in
@@ -132,19 +421,70 @@ class MapAmapThemeControl: UIViewController {
                     }
                 }
             }
-            .store(in: &cancellables)*/
+            .store(in: &cancellables)
+    }*/
+}
+
+
+
+
+// 自定义Polyline包装类
+private class CustomPolyline {
+    let polyline: MAPolyline
+    let id: String
+    let color: String
+    let width: Double
+    
+    init(polyline: MAPolyline, id: String, color: String, width: Double) {
+        self.polyline = polyline
+        self.id = id
+        self.color = color
+        self.width = width
+    }
+}
+
+private class MyMAPointAnnotation : MAPointAnnotation {
+    let itemMarker : ATMapMarker
+    init(itemMarker: ATMapMarker) {
+        self.itemMarker = itemMarker
     }
 }
 
+private class MyMAPolyline : MAPolyline {
+    var itemPolyLine : ATMapPolyline! = nil
+    
+}
 
 
 @available(iOS 13.0, *)
 extension MapAmapThemeControl : MAMapViewDelegate {
     //根据anntation生成对应的View。
     func mapView(_ mapView: MAMapView!, viewFor annotation: MAAnnotation!) -> MAAnnotationView! {
-        if annotation is MAPointAnnotation {
-            let pointReuseIdentifier = "pointReuseIndetifier"
+//        guard let marker = annotation as? ATMapMarker else {
+//            return nil
+//        }
+        
+        if let myitemAnnotation = annotation as? MyMAPointAnnotation {
+            if myitemAnnotation.itemMarker.markerType.isMapAchorPoint {
+                let annotationView = (mapView.dequeueReusableAnnotationView(withIdentifier: MapAnnotationAnchorPointView.identifier) as? MapAnnotationAnchorPointView) ?? MapAnnotationAnchorPointView(annotation: (myitemAnnotation as MAAnnotation), reuseIdentifier: MapAnnotationAnchorPointView.identifier)
+                annotationView!.marker = myitemAnnotation.itemMarker
+                return annotationView
+            } else if (myitemAnnotation.itemMarker.markerType.isTracePopup) {
+                let annotationBubbleView = (mapView.dequeueReusableAnnotationView(withIdentifier: MapAmapPopUpWindowView.identifier) as? MapAmapPopUpWindowView) ?? MapAmapPopUpWindowView(annotation: (myitemAnnotation as MAAnnotation), reuseIdentifier: MapAmapPopUpWindowView.identifier)
+                annotationBubbleView!.marker = myitemAnnotation.itemMarker
+                return annotationBubbleView
+            }
+            let annotationView = (mapView.dequeueReusableAnnotationView(withIdentifier: MapAnnotationView.identifier) as? MapAnnotationView) ?? MapAnnotationView(annotation: (myitemAnnotation as MAAnnotation), reuseIdentifier: MapAnnotationView.identifier)
+            annotationView!.marker = myitemAnnotation.itemMarker
+            return annotationView
+        }
+        return nil
+
+        
+        /*if annotation is MyMAPointAnnotation,let myitemAnnotation = annotation as? MyMAPointAnnotation {
+            
             
+            let pointReuseIdentifier = "pointReuseIndetifier"
             var annotationView = mapView.dequeueReusableAnnotationView(
                 withIdentifier: pointReuseIdentifier
             ) as? MAPinAnnotationView
@@ -164,8 +504,65 @@ extension MapAmapThemeControl : MAMapViewDelegate {
             return annotationView
         }
         
-        return nil
+        return nil*/
     }
+    
+    
+    func mapView(_ mapView: MAMapView!, rendererFor overlay: MAOverlay!) -> MAOverlayRenderer! {
+        guard let polyline = overlay as? MyMAPolyline else {
+              return  MAPolylineRenderer(polyline: overlay as? MAPolyline)
+          }
+        
+        // 外层边框(粗线)
+//        let borderRenderer = MAPolylineRenderer(polyline: polyline)
+//        borderRenderer?.lineWidth = 8
+//        borderRenderer?.strokeColor = UIColor(red: 0.35, green: 0.36, blue: 0.99, alpha: 1)
+//        
+        let renderer = MAPolylineRenderer(polyline: polyline)
+        renderer?.lineWidth = 6
+    //rgba(123, 125, 255, 1)
+        renderer?.fillColor = UIColor(red: 0.27, green: 0.46, blue: 1, alpha: 1)//UIColor.init(hex: "#4476FF");//UIColor(red: 123 / 255, green: 125 / 255, blue: 255 / 255, alpha: 1)
+        renderer?.lineCapType = kMALineCapRound//kMALineCapArrow
+        renderer?.lineJoinType = kMALineJoinRound
+        
+//        renderer?.strokeColor = UIColor(red: 0.35, green: 0.36, blue: 0.99, alpha: 1)
+//        renderer?.miterLimit = 1
+        renderer?.sideColor = UIColor(red: 0.35, green: 0.36, blue: 0.99, alpha: 1)
+        renderer?.is3DArrowLine = true
+
+    // 设置箭头样式
+        // 加载箭头纹理图片
+        renderer?.strokeImage = readImageContentFrom(imageName: "com.shishi.dingwei_uparrow")
+    
+        //normal error selected color
+        if polyline.itemPolyLine.lineType == "normal" {
+            renderer?.strokeColor = UIColor(red: 0.27, green: 0.46, blue: 1, alpha: 1)
+        } else  if polyline.itemPolyLine.lineType == "error" {
+            renderer?.strokeColor = UIColor(red: 1, green: 0.43, blue: 0.43, alpha: 1)
+        } else  if polyline.itemPolyLine.lineType == "selected" {
+            renderer?.strokeColor = UIColor(red: 0.08, green: 0.8, blue: 0.63, alpha: 1)
+        } else if polyline.itemPolyLine.lineType == "color" {
+            renderer?.strokeColor = UIColor(hex: polyline.itemPolyLine.color)
+            renderer?.lineWidth = polyline.itemPolyLine.width
+        }
+        return renderer
+      }
+    
+    
+    private func readImageContentFrom(imageName : String) -> UIImage {
+        if let image = UIImage(named: imageName) {
+            return image
+        }
+        
+        // 尝试从插件资源束加载
+        let bundleURL = Bundle(for: MapAnnotationView.self).url(forResource: "map_amap_ios_image_source", withExtension: "bundle")
+        if let bundleURL = bundleURL, let resourceBundle = Bundle(url: bundleURL) {
+            return UIImage(named: imageName, in: resourceBundle, compatibleWith: nil) ?? UIImage()
+        }
+        
+        return  UIImage()
+    }
+    
 }
 
 

+ 3 - 0
plugins/map_amap_ios/ios/Classes/MapAmapIosPlugin.swift

@@ -2,6 +2,7 @@
 
 import UIKit
 import Flutter
+import AMapFoundationKit
 
 enum MapSupportedPackage: String {
     case traceLocation1 = "com.shishi.dingwei"
@@ -21,6 +22,8 @@ public class MapAmapIosPlugin: NSObject, FlutterPlugin {
     
     public static func register(with registrar: FlutterPluginRegistrar) {
         
+        MapAmapConfigManager.setupMapKey("ed76ac32e33f33d7724936e9efbc2cd2")
+        
         let factory = MapFlutterViewFactory(messenger: registrar.messenger())
         registrar.register(factory,
                            withId: MapAmapViewOnlyKeyword.mapViewId,

BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_friend.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_location_error.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_map_pin.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_mine.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_mine_selected.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_traceEndFriend.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_traceEndMine.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_traceStart.png


BIN
plugins/map_amap_ios/ios/MapAmapImageSource/com.shishi.dingwei_uparrow.png


+ 5 - 0
plugins/map_amap_ios/ios/map_amap_ios.podspec

@@ -21,6 +21,11 @@ A new Flutter plugin project.
   # Flutter.framework does not contain a i386 slice.
   s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
   s.swift_version = '5.0'
+  
+  s.resource_bundles = {
+    'map_amap_ios_image_source' => ['MapAmapImageSource/**/*']
+  }
+
 
   # If your plugin requires a privacy manifest, for example if it uses any
   # required reason APIs, update the PrivacyInfo.xcprivacy file to describe your