Commit dd480009 authored by Qiu Xiang's avatar Qiu Xiang

onStatusChangeComplete 将同时返回 latitudeDelta 和 longitudeDelta

相关:#18
parent 0307603d
...@@ -113,6 +113,12 @@ class AMapView(context: Context) : MapView(context) { ...@@ -113,6 +113,12 @@ class AMapView(context: Context) : MapView(context) {
data.putDouble("rotation", it.bearing.toDouble()) data.putDouble("rotation", it.bearing.toDouble())
data.putDouble("latitude", it.target.latitude) data.putDouble("latitude", it.target.latitude)
data.putDouble("longitude", it.target.longitude) data.putDouble("longitude", it.target.longitude)
if (event == "onCameraChangeFinish") {
val southwest = map.projection.visibleRegion.latLngBounds.southwest
val northeast = map.projection.visibleRegion.latLngBounds.northeast
data.putDouble("latitudeDelta", Math.abs(southwest.latitude - northeast.latitude))
data.putDouble("longitudeDelta", Math.abs(southwest.longitude - northeast.longitude))
}
emit(id, event, data) emit(id, event, data)
} }
} }
......
...@@ -162,13 +162,29 @@ RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *) ...@@ -162,13 +162,29 @@ RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)
- (void)mapViewRegionChanged:(AMapView *)mapView { - (void)mapViewRegionChanged:(AMapView *)mapView {
if (mapView.onStatusChange) { if (mapView.onStatusChange) {
mapView.onStatusChange([self buildStatusData:mapView.getMapStatus]); MAMapStatus *status = mapView.getMapStatus;
mapView.onStatusChange(@{
@"zoomLevel": @(status.zoomLevel),
@"tilt": @(status.cameraDegree),
@"rotation": @(status.rotationDegree),
@"latitude": @(status.centerCoordinate.latitude),
@"longitude": @(status.centerCoordinate.longitude),
});
} }
} }
- (void)mapView:(AMapView *)mapView regionDidChangeAnimated:(BOOL)animated { - (void)mapView:(AMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
if (mapView.onStatusChangeComplete) { if (mapView.onStatusChangeComplete) {
mapView.onStatusChangeComplete([self buildStatusData:mapView.getMapStatus]); MAMapStatus *status = mapView.getMapStatus;
mapView.onStatusChangeComplete(@{
@"zoomLevel": @(status.zoomLevel),
@"tilt": @(status.cameraDegree),
@"rotation": @(status.rotationDegree),
@"latitude": @(status.centerCoordinate.latitude),
@"longitude": @(status.centerCoordinate.longitude),
@"latitudeDelta": @(mapView.region.span.latitudeDelta),
@"longitudeDelta": @(mapView.region.span.longitudeDelta),
});
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment