@fleet-frontend/mower-maps 0.1.0-beta.2 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -11966,7 +11966,7 @@ const MowerMapRenderer = forwardRef(({ edger = false, unitType = UnitsType.Imper
11966
11966
  setCurrentError(error);
11967
11967
  onError?.(error);
11968
11968
  };
11969
- const fitBounds = useCallback(() => {
11969
+ const fitBounds = useCallback((padding = 0) => {
11970
11970
  if (!mapJson || !mapRef)
11971
11971
  return null;
11972
11972
  // 计算边界
@@ -11985,7 +11985,7 @@ const MowerMapRenderer = forwardRef(({ edger = false, unitType = UnitsType.Imper
11985
11985
  const googleBounds = new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), // 西南角
11986
11986
  new window.google.maps.LatLng(neLat, neLng) // 东北角
11987
11987
  );
11988
- mapRef.fitBounds(googleBounds);
11988
+ mapRef.fitBounds(googleBounds, padding);
11989
11989
  }, [mapJson, mapRef, defaultTransform]);
11990
11990
  // 初始化Google Maps叠加层
11991
11991
  const initializeGoogleMapsOverlay = async () => {
@@ -12039,7 +12039,7 @@ const MowerMapRenderer = forwardRef(({ edger = false, unitType = UnitsType.Imper
12039
12039
  overlay.setEdger(edger);
12040
12040
  // 只在首次初始化时自适应视图
12041
12041
  if (!hasInitializedBounds) {
12042
- mapInstance.fitBounds(googleBounds);
12042
+ // mapInstance.fitBounds(googleBounds);
12043
12043
  setHasInitializedBounds(true);
12044
12044
  }
12045
12045
  setIsGoogleMapsReady(true);
@@ -12335,21 +12335,21 @@ const MowerMapRenderer = forwardRef(({ edger = false, unitType = UnitsType.Imper
12335
12335
  }
12336
12336
  }
12337
12337
  }, [realTimeData, mapJson, pathJson]);
12338
- useEffect(() => {
12339
- if (!overlayRef.current || !defaultTransform)
12340
- return;
12341
- overlayRef.current?.setTransform(defaultTransform);
12342
- const validBounds = getValidGpsBounds(mapJson, defaultTransform?.rotation);
12343
- // 地图数据中的坐标格式是 [longitude, latitude]
12344
- const swLat = validBounds.sw[1] + defaultTransform.y;
12345
- const swLng = validBounds.sw[0] + defaultTransform.x;
12346
- const neLat = validBounds.ne[1] + defaultTransform.y;
12347
- const neLng = validBounds.ne[0] + defaultTransform.x;
12348
- const googleBounds = new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), // 西南角
12349
- new window.google.maps.LatLng(neLat, neLng) // 东北角
12350
- );
12351
- mapRef.fitBounds(googleBounds);
12352
- }, [defaultTransform]);
12338
+ // useEffect(() => {
12339
+ // if (!overlayRef.current || !defaultTransform) return;
12340
+ // overlayRef.current?.setTransform(defaultTransform);
12341
+ // const validBounds = getValidGpsBounds(mapJson, defaultTransform?.rotation);
12342
+ // // 地图数据中的坐标格式是 [longitude, latitude]
12343
+ // const swLat = validBounds.sw[1] + defaultTransform.y;
12344
+ // const swLng = validBounds.sw[0] + defaultTransform.x;
12345
+ // const neLat = validBounds.ne[1] + defaultTransform.y;
12346
+ // const neLng = validBounds.ne[0] + defaultTransform.x;
12347
+ // const googleBounds = new window.google.maps.LatLngBounds(
12348
+ // new window.google.maps.LatLng(swLat, swLng), // 西南角
12349
+ // new window.google.maps.LatLng(neLat, neLng) // 东北角
12350
+ // );
12351
+ // mapRef.fitBounds(googleBounds);
12352
+ // }, [defaultTransform]);
12353
12353
  useEffect(() => {
12354
12354
  if (!overlayRef || !overlayRef.current)
12355
12355
  return;
@@ -12357,8 +12357,8 @@ const MowerMapRenderer = forwardRef(({ edger = false, unitType = UnitsType.Imper
12357
12357
  }, [edger]);
12358
12358
  // 提供ref方法
12359
12359
  useImperativeHandle(ref, () => ({
12360
- fitToView: () => {
12361
- fitBounds();
12360
+ fitToView: (padding = 0) => {
12361
+ fitBounds(padding);
12362
12362
  },
12363
12363
  getOverlay: () => {
12364
12364
  return overlayRef.current;
package/dist/index.js CHANGED
@@ -11968,7 +11968,7 @@ const MowerMapRenderer = React.forwardRef(({ edger = false, unitType = UnitsType
11968
11968
  setCurrentError(error);
11969
11969
  onError?.(error);
11970
11970
  };
11971
- const fitBounds = React.useCallback(() => {
11971
+ const fitBounds = React.useCallback((padding = 0) => {
11972
11972
  if (!mapJson || !mapRef)
11973
11973
  return null;
11974
11974
  // 计算边界
@@ -11987,7 +11987,7 @@ const MowerMapRenderer = React.forwardRef(({ edger = false, unitType = UnitsType
11987
11987
  const googleBounds = new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), // 西南角
11988
11988
  new window.google.maps.LatLng(neLat, neLng) // 东北角
11989
11989
  );
11990
- mapRef.fitBounds(googleBounds);
11990
+ mapRef.fitBounds(googleBounds, padding);
11991
11991
  }, [mapJson, mapRef, defaultTransform]);
11992
11992
  // 初始化Google Maps叠加层
11993
11993
  const initializeGoogleMapsOverlay = async () => {
@@ -12041,7 +12041,7 @@ const MowerMapRenderer = React.forwardRef(({ edger = false, unitType = UnitsType
12041
12041
  overlay.setEdger(edger);
12042
12042
  // 只在首次初始化时自适应视图
12043
12043
  if (!hasInitializedBounds) {
12044
- mapInstance.fitBounds(googleBounds);
12044
+ // mapInstance.fitBounds(googleBounds);
12045
12045
  setHasInitializedBounds(true);
12046
12046
  }
12047
12047
  setIsGoogleMapsReady(true);
@@ -12337,21 +12337,21 @@ const MowerMapRenderer = React.forwardRef(({ edger = false, unitType = UnitsType
12337
12337
  }
12338
12338
  }
12339
12339
  }, [realTimeData, mapJson, pathJson]);
12340
- React.useEffect(() => {
12341
- if (!overlayRef.current || !defaultTransform)
12342
- return;
12343
- overlayRef.current?.setTransform(defaultTransform);
12344
- const validBounds = getValidGpsBounds(mapJson, defaultTransform?.rotation);
12345
- // 地图数据中的坐标格式是 [longitude, latitude]
12346
- const swLat = validBounds.sw[1] + defaultTransform.y;
12347
- const swLng = validBounds.sw[0] + defaultTransform.x;
12348
- const neLat = validBounds.ne[1] + defaultTransform.y;
12349
- const neLng = validBounds.ne[0] + defaultTransform.x;
12350
- const googleBounds = new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), // 西南角
12351
- new window.google.maps.LatLng(neLat, neLng) // 东北角
12352
- );
12353
- mapRef.fitBounds(googleBounds);
12354
- }, [defaultTransform]);
12340
+ // useEffect(() => {
12341
+ // if (!overlayRef.current || !defaultTransform) return;
12342
+ // overlayRef.current?.setTransform(defaultTransform);
12343
+ // const validBounds = getValidGpsBounds(mapJson, defaultTransform?.rotation);
12344
+ // // 地图数据中的坐标格式是 [longitude, latitude]
12345
+ // const swLat = validBounds.sw[1] + defaultTransform.y;
12346
+ // const swLng = validBounds.sw[0] + defaultTransform.x;
12347
+ // const neLat = validBounds.ne[1] + defaultTransform.y;
12348
+ // const neLng = validBounds.ne[0] + defaultTransform.x;
12349
+ // const googleBounds = new window.google.maps.LatLngBounds(
12350
+ // new window.google.maps.LatLng(swLat, swLng), // 西南角
12351
+ // new window.google.maps.LatLng(neLat, neLng) // 东北角
12352
+ // );
12353
+ // mapRef.fitBounds(googleBounds);
12354
+ // }, [defaultTransform]);
12355
12355
  React.useEffect(() => {
12356
12356
  if (!overlayRef || !overlayRef.current)
12357
12357
  return;
@@ -12359,8 +12359,8 @@ const MowerMapRenderer = React.forwardRef(({ edger = false, unitType = UnitsType
12359
12359
  }, [edger]);
12360
12360
  // 提供ref方法
12361
12361
  React.useImperativeHandle(ref, () => ({
12362
- fitToView: () => {
12363
- fitBounds();
12362
+ fitToView: (padding = 0) => {
12363
+ fitBounds(padding);
12364
12364
  },
12365
12365
  getOverlay: () => {
12366
12366
  return overlayRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleet-frontend/mower-maps",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.3",
4
4
  "type": "module",
5
5
  "description": "a mower maps in google maps",
6
6
  "main": "dist/index.js",