From 41264c4d763026cd0e6caba6f184a185db36355d Mon Sep 17 00:00:00 2001 From: Akira Date: Mon, 15 Apr 2024 01:57:18 +0900 Subject: [PATCH] =?UTF-8?q?CP=E3=81=AE=E3=83=A9=E3=83=99=E3=83=AB=E3=81=8C?= =?UTF-8?q?=E5=88=87=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/text_util.dart | 6 ++- lib/widgets/map_widget.dart | 73 +++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/lib/utils/text_util.dart b/lib/utils/text_util.dart index 3d49696..9c59e25 100644 --- a/lib/utils/text_util.dart +++ b/lib/utils/text_util.dart @@ -5,13 +5,17 @@ class TextUtils { static String getDisplayTextFeture(GeoJSONFeature f) { RegExp regex = RegExp(r'([.]*0)(?!.*\d)'); String txt = ""; + if (f.properties!["sub_loc_id"] != null) { + txt = "${f.properties!["sub_loc_id"]}"; + } // if(f.properties!["cp"] > 0){ // //print("-- sub-- ${f.properties!["cp"]} ----"); // txt = "${f.properties!["cp"].toString().replaceAll(regex, '')}"; // } //if(f.properties!["buy_point"] != null && f.properties!["buy_point"] > 0){ - txt = "$txt${f.properties!["sub_loc_id"]}"; + //txt = "$txt${f.properties!["sub_loc_id"]}"; //} + //print("Text = ${txt}"); return txt; } diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index 7485bd6..2465e6f 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -140,8 +140,18 @@ class _MapWidgetState extends State { // Widget getMarkerShape(GeoJSONFeature i, BuildContext context) { Widget getMarkerShape(GeoJSONFeature i) { - final String labelText = TextUtils.getDisplayTextFeture(i); - //final double maxWidth = labelText.length * 40.0; + String labelText = TextUtils.getDisplayTextFeture(i); + if( i.properties!['cp'] == 0 ){ + labelText="Start/Goal"; + }else if(i.properties!['cp'] == -1 ){ + labelText="Start"; + }else if(i.properties!['cp'] == -2 ){ + labelText="Goal"; + //}else{ + // labelText=i.properties!['cp']; + } + //debugPrint("Text=${labelText}"); + final double maxWidth = labelText.length * 16.0; GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint; return InkWell( onTap: () { @@ -174,7 +184,7 @@ class _MapWidgetState extends State { child: Stack( fit: StackFit.expand, children: [ - Container( + Container( // マーカー height: 32, width: 32, decoration: BoxDecoration( @@ -193,38 +203,41 @@ class _MapWidgetState extends State { Icons.circle, size: 6.0, ), - i.properties!['cp'] == -1 - ? Transform.translate( - offset: const Offset(18, 0), - child: Transform.rotate( - alignment: Alignment.centerLeft, - origin: Offset.fromDirection(1, 26), - angle: 270 * pi / 180, - child: const Icon( - Icons.play_arrow_outlined, - color: Colors.red, - size: 70, - ), - ), - ) + i.properties!['cp'] <= 0 + ? Transform.translate + ( + offset: const Offset(-3, 0), + child: Transform.rotate( + alignment: Alignment.centerLeft, + origin: Offset.fromDirection(1, 26), + angle: 270 * pi / 180, + child: const Icon( + Icons.play_arrow_outlined, + color: Colors.red, + size: 70, + ), + ), + ) : Container( - color: Colors.transparent, - ), + color: Colors.transparent, + ), ], ), ), Transform.translate( offset: const Offset(30, 0), child: Align( - alignment: Alignment.center, - child: Container( + alignment: Alignment.centerLeft, + child: Container ( + width: 800, // 幅を指定 + height: 40, color: Colors.transparent, - constraints: const BoxConstraints(maxWidth: 500), // 最大幅を設定 + //constraints: const BoxConstraints(maxWidth: 1000), // 最大幅を設定 //constraints: BoxConstraints(maxWidth: maxWidth), // 最大幅を設定 //color: Colors.purple.withOpacity(0.2), child: Stack( children: [ - Text( + Text( // アウトライン labelText, style: TextStyle( fontSize: 16, @@ -234,24 +247,22 @@ class _MapWidgetState extends State { ..strokeWidth = 2 ..color = Colors.white, ), - overflow: TextOverflow.ellipsis, // テキストが長すぎる場合に`...`で省略 - //softWrap: true, // 複数行に渡って表示 - //overflow: TextOverflow.visible, // テキストが切れないように + maxLines: 1, // テキストを1行に制限 + softWrap: false, // テキストの折り返しを無効化 ), - Text( + Text( // テキスト labelText, - //TextUtils.getDisplayTextFeture(i), style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w700, color: Colors.black, ), - overflow: TextOverflow.ellipsis, // テキストが長すぎる場合に`...`で省略 - //softWrap: true, // 複数行に渡って表示 - //overflow: TextOverflow.visible, // テキストが切れないように + maxLines: 1, // テキストを1行に制限 + softWrap: false, // テキストの折り返しを無効化 ), ], ), + ), ), )