https://lbs.qq.com/dev/console/application/mine
去腾讯地图申请key
然后前端页面引用
<script type="text/javascript" src="https://apis.map.qq.com/tools/geolocation/min?key=自己的key&referer=test"></script>
调用代码
let geolocation = new (window).qq.maps.Geolocation('自己的key', 'test');
console.log('geo----',geolocation)
geolocation.getIpLocation(function(position) {
console.log("Latitude is ---",position);
console.log("Latitude is :", position.lat);
console.log("Longitude is :", position.lng);
}, function(error) {
console.error("Error Code = " + error.code + " - " + error.message);
})
部分内容引用自
https://www.jianshu.com/p/e5e99b2110ca