hejianhao
2026-03-12 52d74d8eb447ef865a74ab7f77a5546dbe6a7f5d
fix: 在用户拒绝定位权限时避免调用地图includePoints

当用户拒绝定位权限时,isLocationAuthDenied状态为true,此时调用mapCtx.includePoints会失败。在调用includePoints前添加权限检查,防止在权限被拒绝时执行地图操作。同时扩展权限检查逻辑,将undefined状态也视为权限拒绝。
1个文件已修改
22 ■■■■■ 已修改文件
src/pages/robotaxi/home/index.tsx 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.tsx
@@ -397,10 +397,12 @@
          } else {
            const mapCtx = Taro.createMapContext('map');
            const points = extractPointsFromPolygons(newPolygons);
            mapCtx.includePoints({
              points: points,
              padding: [100, 100, 100, 100]
            });
            if (!isLocationAuthDenied) {
              mapCtx.includePoints({
                points: points,
                padding: [100, 100, 100, 100]
              });
            }
          }
        }
      } else {
@@ -546,7 +548,7 @@
        Taro.getSetting({
          success: (res) => {
            const auth = res.authSetting['scope.userLocation'];
            if (auth === false) {
            if (auth === false || auth === undefined) {
              setIsLocationAuthDenied(true);
              setMapScale(3);
              setLatitude(DEFAULT_LATITUDE);
@@ -1016,10 +1018,12 @@
    const points = extractPointsFromPolygons(nextPolygons);
    if (points.length > 0) {
      const mapCtx = Taro.createMapContext('map');
      mapCtx.includePoints({
        points: points,
        padding: [100, 100, 100, 100]
      });
      if (!isLocationAuthDenied) {
        mapCtx.includePoints({
          points: points,
          padding: [100, 100, 100, 100]
        });
      }
      setTimeout(() => {
        mapCtx.getCenterLocation({
          success: (res) => {