腾讯地图定位

在首页的时候, 我们可能要去对用户进行定位,然后去展示不同的内容给用户浏览

腾讯地图定位完整代码

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
</head>
<body>
<script type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js"></script>
<script src="https://cdn.nikm.cn/js/jquery.js"></script>
<script type="text/JavaScript">
    var geolocation = new qq.maps.Geolocation("YNFBZ-N5BRV-ZCJPS-USFGL-BSMHZ-YZFNZ", "开发调试");
    function showPosition(position) {
        console.log(position);
        console.log('您当前的位置是'+position.province+position.city+position.district+position.addr);
        console.log('您当前的经纬度是'+position.lat+','+position.lng);
    };
    geolocation.getLocation(showPosition);
</script>
</body>
</html>
Last modification:July 6th, 2019 at 05:33 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment

简爱博客