@@ -118,6 +118,13 @@ const VISIT_PATH_COLOR = "#16a34a";
118118/** 訪問予定リスト(旅程)の経路の線・矢印の色。訪問順の経路(緑)・ルートと区別する紫 */
119119const PLAN_LIST_PATH_COLOR = "#9333ea" ;
120120
121+ /**
122+ * 「現在地→訪問予定リスト先頭のスポット」の区間の線・矢印の色。
123+ * GeolocateControlの現在地の青丸(maplibre-gl既定の.maplibregl-user-location-dot)と
124+ * 同じ青にして、現在地から出ている線だと分かるようにする
125+ */
126+ const CURRENT_LOCATION_PATH_COLOR = "#1da1f2" ;
127+
121128/**
122129 * ルートの進行方向を示す右向き矢印(白フチ付き)の画像を色ごとに生成して登録する。
123130 * symbol-placement: "line" のシンボルはライン方向に回転して置かれるため、
@@ -547,9 +554,11 @@ function buildPlanListPath(
547554/**
548555 * ルートと、地図に重ねる色付きの経路(訪問順の経路・訪問予定リストの経路)を
549556 * GeoJSONのLineString群にする。矢印画像の登録もここで済ませる。
550- * `start`([lng, lat])を渡した経路は、その座標を先頭に繋いで描く
551- * (訪問予定リストの経路で「現在地→リスト先頭のスポット」の線を引くのに使う。
552- * 経路のスポットが1件も無いときは始点だけでは線にならないため繋がない)。
557+ * `start`([lng, lat])を渡した経路は、その座標からその経路の先頭までの区間を
558+ * `startColor`(省略時は経路と同色)の別のLineStringとして繋いで描く
559+ * (訪問予定リストの経路で「現在地→リスト先頭のスポット」の線を現在地の青丸と
560+ * 同じ色で引くのに使う。経路のスポットが1件も無いときは始点だけでは線に
561+ * ならないため繋がない)。
553562 */
554563function buildRouteGeoJSON (
555564 map : maplibregl . Map ,
@@ -560,17 +569,27 @@ function buildRouteGeoJSON(
560569 color : string ;
561570 kind ?: "visit" | "plan" ;
562571 start ?: [ number , number ] | null ;
572+ startColor ?: string ;
563573 } [ ]
564574) : GeoJSON . FeatureCollection < GeoJSON . LineString , RouteFeatureProps > {
565575 const extraFeatures : GeoJSON . Feature < GeoJSON . LineString , RouteFeatureProps > [ ] =
566576 extraPaths
567- . map ( ( p ) => ( {
568- ...p ,
569- coordinates : [
570- ...( p . start && p . path . length > 0 ? [ p . start ] : [ ] ) ,
571- ...p . path . map ( ( s ) : [ number , number ] => [ s . lng , s . lat ] ) ,
572- ] ,
573- } ) )
577+ . flatMap ( ( p ) => [
578+ // 始点(現在地)→経路先頭の区間。色を分けられるよう独立した線にする
579+ ...( p . start && p . path . length > 0
580+ ? [
581+ {
582+ ...p ,
583+ color : p . startColor ?? p . color ,
584+ coordinates : [
585+ p . start ,
586+ [ p . path [ 0 ] . lng , p . path [ 0 ] . lat ] as [ number , number ] ,
587+ ] ,
588+ } ,
589+ ]
590+ : [ ] ) ,
591+ { ...p , coordinates : p . path . map ( ( s ) : [ number , number ] => [ s . lng , s . lat ] ) } ,
592+ ] )
574593 . filter ( ( p ) => p . coordinates . length >= 2 )
575594 . map ( ( p ) => ( {
576595 type : "Feature" as const ,
@@ -1217,6 +1236,10 @@ export default function MapView({
12171236 // 経路詳細の「編集」から来た場合、基本情報モーダルは閉じて地図の作成モードに移る
12181237 // (同一ページ遷移のため自動では閉じない。SpotsView からの遷移では unmount で消える)
12191238 setEditingPlanList ( null ) ;
1239+ // スポット詳細の「訪問予定リストへ追加」→「新しいリストを作成」から来た場合も
1240+ // 同じく同一ページ遷移のため、スポット詳細(とその中の追加モーダル・基本情報
1241+ // フォーム)を明示的に閉じる
1242+ setDetailSpotId ( null ) ;
12201243 }
12211244 } , [ buildListParam , spotTypeKey ] ) ;
12221245
@@ -2171,11 +2194,20 @@ export default function MapView({
21712194 color : PLAN_LIST_PATH_COLOR ,
21722195 kind : "plan" ,
21732196 // 現在地(青丸)を表示中は、現在地からリスト先頭のスポットまでも結ぶ
2197+ // (この区間だけ青丸と同じ青)
21742198 start : currentLocation ,
2199+ startColor : CURRENT_LOCATION_PATH_COLOR ,
21752200 } ,
21762201 // 作成モード中の下書きの経路。kind無し=線のタップで詳細は開かない
2177- // (作成中のタップはピンの追加操作を優先するため)
2178- { path : buildDraftPath , color : PLAN_LIST_PATH_COLOR } ,
2202+ // (作成中のタップはピンの追加操作を優先するため)。
2203+ // 保存済みリストの経路表示と同じく、現在地(青丸)を表示中は
2204+ // 現在地から下書き先頭のスポットまでも青で結ぶ
2205+ {
2206+ path : buildDraftPath ,
2207+ color : PLAN_LIST_PATH_COLOR ,
2208+ start : currentLocation ,
2209+ startColor : CURRENT_LOCATION_PATH_COLOR ,
2210+ } ,
21792211 ] )
21802212 ) ;
21812213 } ) ;
@@ -3185,6 +3217,9 @@ export default function MapView({
31853217 onClose = { ( ) => setDetailSpotId ( null ) }
31863218 onVisitChange = { loadVisits }
31873219 onVisitRecorded = { handleVisitRecorded }
3220+ // 既存の訪問予定リストへの追加をリスト一覧へ反映する(経路表示中の
3221+ // リストに追加した場合、地図の紫の経路も引き直される)
3222+ onPlanListChange = { loadPlanLists }
31883223 onSpotChange = { ( spot ) => {
31893224 spotCache . applySpotChange ( spot ) ;
31903225 loadPrivateSpots ( ) ;
0 commit comments