腾讯地图获取地理位置信息

1:去 http://lbs.qq.com/guides/startup.html 注册用户信息;

2:引入<script  type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js" ></script>;

3:function qq_position() {

     var geolocation = new qq.maps.Geolocation(" xx-xx-xx-xx", "myapp"); // xx-xx-xx-xx为开发密钥

      if (geolocation) {
        geolocation.getLocation(success, error);
      } else {
        alert("获取失败");
      }
    },
    function success(position) {
      alert(position.province + position.city + position.addr); // 当前地址为省 + 市 + 详细地址
    },
    function error(err) {
      alert(err);
    },
posted @ 2021-05-24 10:30  奇函数  阅读(799)  评论(0)    收藏  举报