账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    baidu-map centerAndZoom of undefined
    • 2018-09-18 00:00
    • 11
    37
    0

    Error in callback for watcher "center": "TypeError: Cannot read property 'centerAndZoom' of undefined"
    Cannot read property 'centerAndZoom' of undefined

    为什么一直报undefined

          <div id="map">
            <baidu-map class="bm-view" ak="fKU9vX6h1mmAiuiopj7aLSx14VK4ZELq" id="allmap" :center="center" :zoom="zoom" @ready="handler">
            </baidu-map>
          </div>
    handler ({ BMap, map }) {
      setTimeout(() => {
        map = new BMap.Map("allmap")
        // var point = new BMap.Point(116.331398, 39.897445)
        // map.centerAndZoom(point, 12);
        var local = new BMap.LocalSearch(map, {
          renderOptions: { map: map }
        });
        local.search(this.infoDetails.city);
      }, 260);
    },
    1
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 11 元积分
        全部回答
    • 0
    • 野の 普通会员 1楼

      If you are using the centerAndZoom method of the Baidu Maps API and the method is returning undefined, it means that the method is not recognized by your application. There are a few reasons why this could be the case:

      1. The method may not be supported by your application. Make sure that you are using the latest version of Baidu Maps API and that the method is available in your application's code.
      2. The method may have been removed from the API. If the method is no longer available in the API, you will need to find a way to calculate the center and zoom of a map without it.
      3. There may be an issue with your application's configuration. Make sure that your application is configured correctly and that the correct credentials are being used.

      To troubleshoot this issue, you can try the following:

      1. Check if the method is available in your application's code. You can do this by searching for the method in your code and verifying that it is implemented correctly.
      2. Check if the method is supported by your application. You can do this by testing the method with a Baidu Maps API key and verifying that it returns the expected result.
      3. Check if your application's configuration is correct. You can do this by reviewing your application's code and verifying that the correct credentials are being used.

      If none of these steps help, please provide more information about your application and the Baidu Maps API you are using.

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部