百度地图api:
_this.$jquery.ajax({
url:
"http://api.map.baidu.com/location/ip?ip&v=2.0&ak=百度地图密钥&callback=showLocation",
type: "POST",
async: false,
dataType: "jsonp",
success: function (data) {
//获取城市
if (data.status === 0) {
ipaddr = data.content;
}
},error:function(XMLHttpRequerst,status,errorThrown){
ipaddr = "";
},
});
腾讯地图api:
_this.$jquery.ajax({
url:
"https://apis.map.qq.com/ws/location/v1/ip?callback=showLocation&key=腾讯地图密钥&output=jsonp",
type: "POST",
async: false,
dataType: "jsonp",
success: function (data) {
//获取城市
if (data.status === 0) {
ipaddr = data.content;
}
},error:function(XMLHttpRequerst,status,errorThrown){
ipaddr = "";
},
});
搜狐api:
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
console.log(returnCitySN["cip"]+','+returnCitySN["cname")
</script>
新浪api:
<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
<script>
var data = remote_ip_info;
console.log(data.country+" ; "+data.province+" ; "+data.city+" ; ")
</script>