CPのラベルが切れている

This commit is contained in:
2024-04-15 01:57:18 +09:00
parent 4ef42216f8
commit 41264c4d76
2 changed files with 47 additions and 32 deletions

View File

@ -5,13 +5,17 @@ class TextUtils {
static String getDisplayTextFeture(GeoJSONFeature f) { static String getDisplayTextFeture(GeoJSONFeature f) {
RegExp regex = RegExp(r'([.]*0)(?!.*\d)'); RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
String txt = ""; String txt = "";
if (f.properties!["sub_loc_id"] != null) {
txt = "${f.properties!["sub_loc_id"]}";
}
// if(f.properties!["cp"] > 0){ // if(f.properties!["cp"] > 0){
// //print("-- sub-- ${f.properties!["cp"]} ----"); // //print("-- sub-- ${f.properties!["cp"]} ----");
// txt = "${f.properties!["cp"].toString().replaceAll(regex, '')}"; // txt = "${f.properties!["cp"].toString().replaceAll(regex, '')}";
// } // }
//if(f.properties!["buy_point"] != null && f.properties!["buy_point"] > 0){ //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; return txt;
} }

View File

@ -140,8 +140,18 @@ class _MapWidgetState extends State<MapWidget> {
// Widget getMarkerShape(GeoJSONFeature i, BuildContext context) { // Widget getMarkerShape(GeoJSONFeature i, BuildContext context) {
Widget getMarkerShape(GeoJSONFeature i) { Widget getMarkerShape(GeoJSONFeature i) {
final String labelText = TextUtils.getDisplayTextFeture(i); String labelText = TextUtils.getDisplayTextFeture(i);
//final double maxWidth = labelText.length * 40.0; 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; GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint;
return InkWell( return InkWell(
onTap: () { onTap: () {
@ -174,7 +184,7 @@ class _MapWidgetState extends State<MapWidget> {
child: Stack( child: Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
Container( Container( // マーカー
height: 32, height: 32,
width: 32, width: 32,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -193,38 +203,41 @@ class _MapWidgetState extends State<MapWidget> {
Icons.circle, Icons.circle,
size: 6.0, size: 6.0,
), ),
i.properties!['cp'] == -1 i.properties!['cp'] <= 0
? Transform.translate( ? Transform.translate
offset: const Offset(18, 0), (
child: Transform.rotate( offset: const Offset(-3, 0),
alignment: Alignment.centerLeft, child: Transform.rotate(
origin: Offset.fromDirection(1, 26), alignment: Alignment.centerLeft,
angle: 270 * pi / 180, origin: Offset.fromDirection(1, 26),
child: const Icon( angle: 270 * pi / 180,
Icons.play_arrow_outlined, child: const Icon(
color: Colors.red, Icons.play_arrow_outlined,
size: 70, color: Colors.red,
), size: 70,
), ),
) ),
)
: Container( : Container(
color: Colors.transparent, color: Colors.transparent,
), ),
], ],
), ),
), ),
Transform.translate( Transform.translate(
offset: const Offset(30, 0), offset: const Offset(30, 0),
child: Align( child: Align(
alignment: Alignment.center, alignment: Alignment.centerLeft,
child: Container( child: Container (
width: 800, // 幅を指定
height: 40,
color: Colors.transparent, color: Colors.transparent,
constraints: const BoxConstraints(maxWidth: 500), // 最大幅を設定 //constraints: const BoxConstraints(maxWidth: 1000), // 最大幅を設定
//constraints: BoxConstraints(maxWidth: maxWidth), // 最大幅を設定 //constraints: BoxConstraints(maxWidth: maxWidth), // 最大幅を設定
//color: Colors.purple.withOpacity(0.2), //color: Colors.purple.withOpacity(0.2),
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
Text( Text( // アウトライン
labelText, labelText,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
@ -234,24 +247,22 @@ class _MapWidgetState extends State<MapWidget> {
..strokeWidth = 2 ..strokeWidth = 2
..color = Colors.white, ..color = Colors.white,
), ),
overflow: TextOverflow.ellipsis, // テキストが長すぎる場合に`...`で省略 maxLines: 1, // テキストを1行に制限
//softWrap: true, // 複数行に渡って表示 softWrap: false, // テキストの折り返しを無効化
//overflow: TextOverflow.visible, // テキストが切れないように
), ),
Text( Text( // テキスト
labelText, labelText,
//TextUtils.getDisplayTextFeture(i),
style: const TextStyle( style: const TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: Colors.black, color: Colors.black,
), ),
overflow: TextOverflow.ellipsis, // テキストが長すぎる場合に`...`で省略 maxLines: 1, // テキストを1行に制限
//softWrap: true, // 複数行に渡って表示 softWrap: false, // テキストの折り返しを無効化
//overflow: TextOverflow.visible, // テキストが切れないように
), ),
], ],
), ),
), ),
), ),
) )