fix map marker width

This commit is contained in:
Timi
2025-12-18 19:21:46 +08:00
parent 186a74bc77
commit 6f74559c01
11 changed files with 130 additions and 128 deletions

View File

@ -9,20 +9,17 @@
width: 100%;
height: 100%;
.custom-callout {
.marker {
width: fit-content;
padding: 12rpx 16rpx;
display: flex;
min-width: 300rpx;
max-width: 400rpx;
background: var(--theme-bg-card-secondary);
background: var(--theme-bg-card);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
border-radius: 6rpx;
flex-direction: column;
.location-item {
.location {
display: flex;
padding: 6rpx 0;
padding: 8rpx 16rpx 8rpx 8rpx;
align-items: center;
.type {
@ -37,6 +34,7 @@
.title {
flex: 1;
width: calc(var(--title-length) * 28rpx);
color: var(--theme-text-primary, #333);
overflow: hidden;
font-size: 28rpx;

View File

@ -2,6 +2,7 @@
import { TravelLocationApi } from "../../../api/TravelLocationApi";
import { TravelLocation, TravelLocationTypeLabel } from "../../../types/Travel";
import Toolkit from "../../../utils/Toolkit";
interface MapMarker {
id: number;
@ -110,7 +111,8 @@ Page({
height: 30,
customCallout: {
anchorY: -2,
anchorX: 0,
// 随机错位避免近距离重叠
anchorX: Toolkit.random(-10, 10),
display: "ALWAYS"
},
locations: locs

View File

@ -13,16 +13,25 @@
bindcallouttap="onCalloutTap"
>
<cover-view slot="callout">
<block wx:for="{{markers}}" wx:key="id" wx:for-index="markerIndex">
<cover-view class="custom-callout" marker-id="{{markerIndex}}">
<block wx:for="{{item.locations}}" wx:key="id" wx:for-item="location">
<cover-view class="location-item">
<cover-view wx:if="{{location.typeLabel}}" class="type">{{location.typeLabel}}</cover-view>
<cover-view class="title">{{location.title || '未命名地点'}}</cover-view>
</cover-view>
</block>
<cover-view
class="marker"
wx:for="{{markers}}"
wx:key="id"
wx:for-item="marker"
wx:for-index="markerIndex"
marker-id="{{markerIndex}}"
>
<cover-view
class="location"
wx:for="{{marker.locations}}"
wx:key="id"
wx:for-item="location"
style="{{'--title-length: ' + location.title.length}}"
>
<cover-view wx:if="{{location.typeLabel}}" class="type">{{location.typeLabel}}</cover-view>
<cover-view class="title">{{location.title || '未命名地点'}}</cover-view>
</cover-view>
</block>
</cover-view>
</cover-view>
</map>
<view wx:if="{{isLoading}}" class="loading">