Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

点击当前位置的大头针有问题 #34

Open
Dronaldo17 opened this issue May 17, 2017 · 0 comments
Open

点击当前位置的大头针有问题 #34

Dronaldo17 opened this issue May 17, 2017 · 0 comments

Comments

@Dronaldo17
Copy link

原来写法

  • (MAAnnotationView*)mapView:(MAMapView *)mapView viewForAnnotation:(id )annotation
    {
    if ([annotation isKindOfClass:[MAPointAnnotation class]])
    {
    MAPointAnnotation *pointAnnotation = (MAPointAnnotation *)annotation;
    if ([pointAnnotation.component isKindOfClass:[WXMapInfoWindowComponent class]]) {
    return [self _generateCustomInfoWindow:mapView viewForAnnotation:pointAnnotation];

      }else {
          return [self _generateAnnotationView:mapView viewForAnnotation:pointAnnotation];
      }
    

    }

    return nil;
    }

会有一个问题,当前大头针的类为 MAUserLocation,所以上述代码会崩溃,如果有开发者遇到此类问题 ,参考我一下代码

  • (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view
    {
    MAPointAnnotation *annotation = view.annotation;
    for (WXComponent *component in self.subcomponents) {
    if ([component isKindOfClass:[WXMapViewMarkerComponent class]]) {

          if ([annotation isKindOfClass:[MAUserLocation class]]) {
              
          }
      
          else if (annotation.component) {
              if ([component.ref isEqualToString:annotation.component.ref]) {
                  WXMapViewMarkerComponent *marker = (WXMapViewMarkerComponent *)component;
                  if (marker.clickEvent) {
                      [marker fireEvent:marker.clickEvent params:[NSDictionary dictionary]];
                  }
    
              }
          }
          else{
          
          }
       }
    

    }
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant