diff --git a/packages/plugins/@nocobase/plugin-map/src/client/components/GoogleMaps/Map.tsx b/packages/plugins/@nocobase/plugin-map/src/client/components/GoogleMaps/Map.tsx index f8533792bc..631e154fed 100644 --- a/packages/plugins/@nocobase/plugin-map/src/client/components/GoogleMaps/Map.tsx +++ b/packages/plugins/@nocobase/plugin-map/src/client/components/GoogleMaps/Map.tsx @@ -164,9 +164,9 @@ export const GoogleMapsComponent = React.forwardRef { - if (map.current) { - map.current.setCenter(position); - map.current.setZoom(zoom); + if (map.current && position) { + map.current?.setCenter(position); + map.current?.setZoom(zoom); } }); @@ -192,7 +192,7 @@ export const GoogleMapsComponent = React.forwardRef { @@ -386,7 +386,6 @@ export const GoogleMapsComponent = React.forwardRef Promise<{ lat: number; lng: number }> = ( () => { defaultLatLng(); }, + { + timeout: 2000, // 设置最大等待时间,单位毫秒 + maximumAge: 0, // 不使用缓存的地理位置 + }, ); } else { defaultLatLng();