|
@@ -32,6 +32,7 @@ export const DageMap = forwardRef<DageMapMethods, DageMapProps>(
|
|
|
onAddressChange,
|
|
|
onLngLatChange,
|
|
|
onMapComplete,
|
|
|
+ onError,
|
|
|
},
|
|
|
ref
|
|
|
) => {
|
|
@@ -180,12 +181,7 @@ export const DageMap = forwardRef<DageMapMethods, DageMapProps>(
|
|
|
)
|
|
|
) {
|
|
|
// 超出市区范围
|
|
|
- outCityAreaMessage && message.error(outCityAreaMessage, 2);
|
|
|
- setTimeout(() => {
|
|
|
- setLat(prevPosition.current[1]);
|
|
|
- setLng(prevPosition.current[0]);
|
|
|
- handlePosition(prevPosition.current[0], prevPosition.current[1]);
|
|
|
- }, 2000);
|
|
|
+ handleOutCityAreaError();
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -193,6 +189,16 @@ export const DageMap = forwardRef<DageMapMethods, DageMapProps>(
|
|
|
prevPosition.current = [lng, lat];
|
|
|
};
|
|
|
|
|
|
+ const handleOutCityAreaError = () => {
|
|
|
+ outCityAreaMessage && message.error(outCityAreaMessage, 2);
|
|
|
+ onError?.();
|
|
|
+ setTimeout(() => {
|
|
|
+ setLat(prevPosition.current[1]);
|
|
|
+ setLng(prevPosition.current[0]);
|
|
|
+ handlePosition(prevPosition.current[0], prevPosition.current[1]);
|
|
|
+ }, 2000);
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<div>
|
|
@@ -255,6 +261,7 @@ export const DageMap = forwardRef<DageMapMethods, DageMapProps>(
|
|
|
city={city}
|
|
|
position={position}
|
|
|
onChange={handleGeocoderAddress}
|
|
|
+ onError={handleOutCityAreaError}
|
|
|
/>
|
|
|
)}
|
|
|
</>
|