商圈管理默认展示石河子市的地图
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled

This commit is contained in:
francis-fh
2026-06-08 16:36:42 +08:00
parent 3bbd06e90b
commit e499a1a7d7

View File

@@ -23,6 +23,10 @@ export const aMapConfig = {
securityJsCode: '7b16386c7f744c3ca05595965f2b037f', securityJsCode: '7b16386c7f744c3ca05595965f2b037f',
}; };
/** 石河子市地图默认中心点与行政区划编码 */
export const SHIHEZI_MAP_CENTER: [number, number] = [86.041075, 44.305886];
export const SHIHEZI_CITY_CODE = '659001';
const ProFromMap: React.FC<MapProps> = ({ open, onSelect, onCancel }) => { const ProFromMap: React.FC<MapProps> = ({ open, onSelect, onCancel }) => {
const mapRef = useRef<any>(null); const mapRef = useRef<any>(null);
const geocoderRef = useRef<any>(null); const geocoderRef = useRef<any>(null);
@@ -50,9 +54,9 @@ const ProFromMap: React.FC<MapProps> = ({ open, onSelect, onCancel }) => {
// 设置地图容器id // 设置地图容器id
viewMode: '3D', // 是否为3D地图模式 viewMode: '3D', // 是否为3D地图模式
zoom: 11, // 初始化地图级别 zoom: 11, // 初始化地图级别
center: [120.384599, 36.062687], // 初始化地图中心点位置 center: SHIHEZI_MAP_CENTER, // 默认展示石河子市
}); });
// 浏览器定位 // 浏览器定位(仅提供手动定位按钮,不自动跳转以免覆盖默认区域)
AMap.plugin('AMap.Geolocation', function () { AMap.plugin('AMap.Geolocation', function () {
var geolocation = new AMap.Geolocation({ var geolocation = new AMap.Geolocation({
enableHighAccuracy: false, //是否使用高精度定位,默认:true enableHighAccuracy: false, //是否使用高精度定位,默认:true
@@ -62,14 +66,13 @@ const ProFromMap: React.FC<MapProps> = ({ open, onSelect, onCancel }) => {
zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点 zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
}); });
mapRef.current.addControl(geolocation); mapRef.current.addControl(geolocation);
geolocation.getCurrentPosition();
}); });
// 添加插件 // 添加插件
AMap.plugin('AMap.AutoComplete', function () { AMap.plugin('AMap.AutoComplete', function () {
// 注意输入提示插件2.0版本需引入AMap.AutoComplete而1.4版本应使用AMap.Autocomplete // 注意输入提示插件2.0版本需引入AMap.AutoComplete而1.4版本应使用AMap.Autocomplete
// 实例化AutoComplete // 实例化AutoComplete
autoCompleteRef.current = new AMap.AutoComplete({ autoCompleteRef.current = new AMap.AutoComplete({
city: '370200', // 青岛市 city: SHIHEZI_CITY_CODE,
citylimit: false, citylimit: false,
}); });
}); });
@@ -79,7 +82,7 @@ const ProFromMap: React.FC<MapProps> = ({ open, onSelect, onCancel }) => {
geocoderRef.current = new AMap.Geocoder({ geocoderRef.current = new AMap.Geocoder({
extensions: 'base', extensions: 'base',
batch: false, batch: false,
city: '370200', // 青岛市 city: SHIHEZI_CITY_CODE,
}); });
}); });
@@ -155,7 +158,7 @@ const ProFromMap: React.FC<MapProps> = ({ open, onSelect, onCancel }) => {
} }
const searchLocation = async (keyWords: string) => { const searchLocation = async (keyWords: string) => {
const keywordsToSearch = keyWords || '青岛'; const keywordsToSearch = keyWords || '石河子';
const resData = await autoInput(keywordsToSearch); const resData = await autoInput(keywordsToSearch);
locationList.current = resData; locationList.current = resData;
setLocationOptions(resData); setLocationOptions(resData);