Amap-for-Apache-Weex
Amap-for-Apache-Weex copied to clipboard
点击当前位置的大头针有问题
原来写法
-
(MAAnnotationView*)mapView:(MAMapView *)mapView viewForAnnotation:(id <MAAnnotation>)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{ } }
} }