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.getRegion及getScale #5241

Open
Particaly opened this issue Dec 4, 2024 · 5 comments
Open

H5平台无法使用map.getRegion及getScale #5241

Particaly opened this issue Dec 4, 2024 · 5 comments
Assignees
Labels

Comments

@Particaly
Copy link

如题,H5端无法使用mapContext来调用getRegion及getScale,两者的返回值都是undefined
企业微信截图_17332972335011

@Otto-J Otto-J added the 地图问题 map label Mar 5, 2025
@GRCmade
Copy link
Collaborator

GRCmade commented Mar 5, 2025

hello , 你这个 temp1 是如何产生的? 提供一下你的代码。

使用这个方法需要:uni.createMapContext("map", this);

@GRCmade GRCmade self-assigned this Mar 5, 2025
@HengSvr
Copy link

HengSvr commented Mar 8, 2025

getRegion和getScale方法都是通过回调方式返回数据

uni.createMapContext('myMap').getRegion({
  success: function (res) {
    console.log('视野范围:', res);
  },
  fail: function (err) {
    console.error('获取视野范围失败:', err);
  }
});

@GRCmade
Copy link
Collaborator

GRCmade commented Mar 10, 2025

getRegion和getScale方法都是通过回调方式返回数据

uni.createMapContext('myMap').getRegion({
success: function (res) {
console.log('视野范围:', res);
},
fail: function (err) {
console.error('获取视野范围失败:', err);
}
});

hello,你是在哪个版本产生的问题?更新到最新版也会有吗?

@HengSvr
Copy link

HengSvr commented Mar 10, 2025

getRegion和getScale方法都是通过回调方式返回数据
uni.createMapContext('myMap').getRegion({
success: function (res) {
console.log('视野范围:', res);
},
fail: function (err) {
console.error('获取视野范围失败:', err);
}
});

hello,你是在哪个版本产生的问题?更新到最新版也会有吗?

当前版本是:3.0.0
测试环境:Google Chrome 133.0.6943.142

<template>
  <map
      id="unimap"
      class="w-750 h-full"
      :longitude="centerPoint.longitude"
      :latitude="centerPoint.latitude"
      :scale="mapScale"
      @markertap="markertap"
      @regionchange="regionchange"
  ></map>
</template>

<script setup>
import { onMounted } from 'vue';

onMounted(() => {
    uni.createMapContext('unimap').getRegion({
        success: function (res) {
            console.log('视野范围:', res);
        },
        fail: function (err) {
            console.error('获取视野范围失败:', err);
        },
        complete: () => {}
    });
});

async function regionchange(event) {
    console.log('范围变化', event);
    if (event.type !== 'end') return;

    uni.createMapContext('unimap').getRegion({
        success: function (res) {
            console.log('视野范围:', res);
        },
        fail: function (err) {
            console.error('获取视野范围失败:', err);
        },
        complete: () => {}
    });
}
</script>

在onMounted时,可以获取到视野范围,在regionchange事件响应方法中,getRegion方法无响应,并且未捕获到异常

Image

@GRCmade
Copy link
Collaborator

GRCmade commented Mar 12, 2025

感谢反馈,能够复现,之后会排查一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants