Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H5 Map组件高德地图callout弹出后立即自动关闭 #4574

Open
nadirvishun opened this issue Oct 23, 2023 · 0 comments
Open

H5 Map组件高德地图callout弹出后立即自动关闭 #4574

nadirvishun opened this issue Oct 23, 2023 · 0 comments
Assignees

Comments

@nadirvishun
Copy link

nadirvishun commented Oct 23, 2023

问题描述
H5 Map组件高德地图callout弹出后立即自动关闭,貌似触发了两次,但奇怪的是前几个月时还正常,最近突然不行了,也没有做过版本更新。

复现步骤

<template>
  <view class="content">
    <map
      ref="map"
      id="map"
      class="map"
      :latitude="latitude"
      :longitude="longitude"
      :markers="markers"
      :polyline="polyline"
      :include-points="points"
    >
    </map>
  </view>
</template>

<script>
export default {
  data() {
    return {
      title: "Hello",
      markerIcon: require("@/static/marker.png"),
      latitude: null,
      longitude: null,
      markers: [],
      polyline: [],
      points: [],
    };
  },
  onReady() {
    this.initMap();
  },
  methods: {
    initMap() {
      let data = [
        {
          longitude: 116.284451,
          latitude: 39.823066,
        },
        {
          longitude: 117.064522,
          latitude: 40.133483,
        },
        {
          longitude: 117.093158,
          latitude: 40.14781,
        },
      ];
      let markers = [];
      let points = [];
      let i = 0;
      for (let item of data) {
        if (i === 0) {
          this.latitude = item.latitude;
          this.longitude = item.longitude;
        }
        let marker = {
          latitude: item.latitude,
          longitude: item.longitude,
          iconPath: this.markerIcon,
          width: 25,
          height: 25,
          callout: {
            //自定义标记点上方的气泡窗口 点击有效
            content: "测试", //文本
            padding: 5,
            color: "#ffffff", //文字颜色
            fontSize: 14, //文本大小
            borderRadius: 2, //边框圆角
            bgColor: "#00c16f", //背景颜色
            display: "BYCLICK", //常显
          },
        };
        markers.push(marker);
        let point = {
          latitude: item.latitude,
          longitude: item.longitude,
        };
        points.push(point);
        i++;
      }
      this.markers = markers;
      this.points = points;
      this.polyline = [
        {
          points: points,
          color: "#0081ff",
          width: 3,
          arrowLine: true,
          dottedLine: true,
        },
      ];
    },
  },
};
</script>

<style>
.map {
  width: 100%;
  height: 400px;
}
</style>

预期结果
正常应该点击marker后显示,再次点击关闭

实际结果
点击marker后闪烁
动画

系统信息:

  • 发行平台:H5平台
  • 操作系统:windows浏览器和企业微信浏览器
  • uni-app版本:uni-app v3.7.8 uni-app cli v2.0.2-3070820230322001
  • 设备信息::安卓浏览器及edge浏览器的移动调试模式

补充信息

  • 将浏览器的移动调试模式取消,也就时在PC端测试就正常。
  • 怀疑是map-marker.js中同时监听了clicktouchend,然后两个都触发了,是否应该先增加touched监听,然后在监听方法中通过 e.preventDefault()来阻止click事件触发,在callout.js文件中也有类似的同时监听的代码。
  • 但奇怪的是,我几个月前测试时是正常的,看代码提交时间同时监听的逻辑也早就有了,很怪。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants