无故事王国
2023-11-08 5f9cd3ae516f510a9475fd11f440fedf027aa4df
WanPai/Root/Search/VC/SearchVC.swift
@@ -61,14 +61,15 @@
        mapView.frame = CGRect(origin: .zero, size: view_container.size)
      for (index,v) in models.enumerated(){
            let point = MAPointAnnotation()
            let point = CustomPointAnnotation()
            point.coordinate = CLLocationCoordinate2D(latitude: v.latitude, longitude:v.longitude)
            point.title = v.storeName
            point.title = v.storeAddr
         point.index = index
         v.index = index
            v.annotation = point
        }
        let points = models.map({$0.annotation}) as! [MAPointAnnotation]
        let points = models.map({$0.annotation}) as! [CustomPointAnnotation]
        mapView.addAnnotations(points)
        mapView.showAnnotations(points, animated: true)
        mapView.selectAnnotation(points.first!, animated: true)
@@ -167,12 +168,13 @@
extension SearchVC:MAMapViewDelegate{
    func mapView(_ mapView: MAMapView!, viewFor annotation: MAAnnotation!) -> MAAnnotationView! {
        if annotation is MAPointAnnotation{
            var pointView =  mapView.dequeueReusableAnnotationView(withIdentifier: "point")
        if annotation is CustomPointAnnotation{
            var pointView =  mapView.dequeueReusableAnnotationView(withIdentifier: "point") as? CustomPointAnnotationView
            if pointView == nil{
                pointView = MAAnnotationView(annotation: annotation, reuseIdentifier: "point")
                pointView = CustomPointAnnotationView(annotation: annotation, reuseIdentifier: "point")
            }
            pointView?.canShowCallout = true
         pointView?.label.text = "\((annotation as! CustomPointAnnotation).index + 1)"
            pointView?.image = UIImage(named: "icon_point")?.withTintColor(UIColor(hexStr: "#f54444"))
            return pointView
        }