hejianhao
2026-03-12 a1de653389f0f4ccd0659cdaaa6246e3d4524a43
fix: 优化地图显示逻辑与站点搜索过滤

- 在订单详情页中,当 polyline 数据无效时,使用 markers 数据来调整地图显示范围
- 在站点搜索页中,当选择终点时,过滤掉与起点相同 ID 或坐标的附近站点
2个文件已修改
53 ■■■■■ 已修改文件
src/robotaxi/pages/order/detail/index.tsx 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/index.tsx 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/order/detail/index.tsx
@@ -144,13 +144,32 @@
  };
  useEffect(() => {
    if (!polyline.length || !polyline[0]?.points?.length) return;
    const mapCtx = Taro.createMapContext('trip-map');
    mapCtx.includePoints({
      points: polyline[0].points,
      padding: [40, 40, 40, 40]
    })
  }, [polyline])
    const polylinePoints = polyline?.[0]?.points;
    if (Array.isArray(polylinePoints) && polylinePoints.length > 0) {
      mapCtx.includePoints({
        points: polylinePoints,
        padding: [40, 40, 40, 40]
      });
      return;
    }
    if (Array.isArray(markers) && markers.length > 0) {
      const markerPoints = markers
        .map((item) => {
          const longitude = Number(item?.longitude);
          const latitude = Number(item?.latitude);
          if (Number.isNaN(longitude) || Number.isNaN(latitude)) return null;
          return { longitude, latitude };
        })
        .filter(Boolean) as Array<{ longitude: number; latitude: number }>;
      if (markerPoints.length > 0) {
        mapCtx.includePoints({
          points: markerPoints,
          padding: [40, 40, 40, 40]
        });
      }
    }
  }, [polyline, markers])
  const todescription = () => {
    Taro.navigateTo({
src/robotaxi/pages/site-search/index.tsx
@@ -315,9 +315,25 @@
    }
  }
  const recommendList = searchValue
    ? siteList
    : (pageType === 'end' && Taro.getStorageSync('startSite') ? [] : nearbySiteList);
  const startSiteCache = pageType === 'end' ? Taro.getStorageSync('startSite') : null;
  const filteredNearbyList = pageType === 'end' && startSiteCache
    ? nearbySiteList.filter((item: any) => {
      const startId = startSiteCache?.id;
      const itemId = item?.id;
      if (startId && itemId) {
        return String(startId) !== String(itemId);
      }
      const startLng = Number(startSiteCache?.longitude);
      const startLat = Number(startSiteCache?.latitude);
      const itemLng = Number(item?.longitude);
      const itemLat = Number(item?.latitude);
      if (!Number.isNaN(startLng) && !Number.isNaN(startLat) && !Number.isNaN(itemLng) && !Number.isNaN(itemLat)) {
        return startLng !== itemLng || startLat !== itemLat;
      }
      return true;
    })
    : nearbySiteList;
  const recommendList = searchValue ? siteList : filteredNearbyList;
  const visibleHistory = showAllHistory ? historySite.slice(0, MAX_EXPANDED_COUNT) : historySite.slice(0, MAX_SHOW_COUNT);
  const visibleRecommend = showAllRecommend ? recommendList.slice(0, MAX_EXPANDED_COUNT) : recommendList.slice(0, MAX_SHOW_COUNT);