js 通过腾讯地图api简单获取地理位置信息

腾讯ip定位:https://lbs.qq.com/service/webService/webServiceGuide/webServiceIp

申请一个腾讯地图key:https://lbs.qq.com/dev/console/key/manage

使用方法如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>test</title>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
    
</body>
<script>
    $.ajax({
        type:'get',
        url:'https://apis.map.qq.com/ws/location/v1/ip',
        data:{
            key:'NUMBZ-QW4RF-CLQJI-J5A77-XIRM3-26BWY', //腾讯key(我的测试key)
            output:'jsonp',
        },
        dataType: 'jsonp',
        success:function (res){
            console.log(res)
        }
    })
</script>
</html>

 

posted @ 2020-05-11 16:34  男孩亮亮  阅读(7285)  评论(0编辑  收藏  举报