|
@@ -34,6 +34,48 @@ export default () => {
|
|
|
};
|
|
|
```
|
|
|
|
|
|
+### 仅限规定市区内范围搜索
|
|
|
+
|
|
|
+设置 `onlyCityArea` 为 `true`,并且 `city` 值为 `number` 类型生效
|
|
|
+
|
|
|
+```tsx
|
|
|
+import React, { useCallback, useEffect, useState } from "react";
|
|
|
+import { DageMap, DageMapLngLatChangeEvent } from "@dage/pc-components";
|
|
|
+
|
|
|
+export default () => {
|
|
|
+ const [position, setPosition] = useState([121.473581, 31.230536]);
|
|
|
+ const [address, setAddress] = useState("上海市人民政府");
|
|
|
+
|
|
|
+ const handleAddressChange = useCallback((val: string) => {
|
|
|
+ setAddress(val);
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ const handleLngLatChange = useCallback((data: DageMapLngLatChangeEvent) => {
|
|
|
+ setPosition([data.lng, data.lat]);
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ setPosition([121.474085, 31.231271]);
|
|
|
+ }, 2000);
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ return (
|
|
|
+ <DageMap
|
|
|
+ city={310000}
|
|
|
+ onlyCityArea={true}
|
|
|
+ outCityAreaMessage="请在上海市内搜索"
|
|
|
+ longitude={position[0]}
|
|
|
+ latitude={position[1]}
|
|
|
+ inputTipsApi="https://sit-shgybwg.4dage.com/api/cms/goods/mapSearch/"
|
|
|
+ address={address}
|
|
|
+ onLngLatChange={handleLngLatChange}
|
|
|
+ onAddressChange={handleAddressChange}
|
|
|
+ />
|
|
|
+ );
|
|
|
+};
|
|
|
+```
|
|
|
+
|
|
|
### 地图禁用
|
|
|
|
|
|
```tsx
|