腾讯地图的输入提示
$.ajax({
type: 'get',
async : false,
dataType:"jsonp",
url: "https://apis.map.qq.com/ws/place/v1/suggestion?output=jsonp",
data : {
region:"全国",
keyword:text,
key:"HJ5BZ-AJA6F-5Z6JV-JBTV6-SOXHH-WYBWS",
},
success: function(result){
var list = result.data;
var strHtml = '';
if((result.status == 0) && (list.length != 0)){
for (var i=0;i<list.length;i++) {
var dispose = list[i].title;
if(list[i].title.includes(list[i].province)){
dispose = list[i].title.split(list[i].province)[1]
}
if(dispose.includes(list[i].city)){
dispose = dispose.split(list[i].city)[1];
}
if(dispose.includes(list[i].district)){
dispose = dispose.split(list[i].district)[1];
}
strHtml=strHtml+ `<div class="weui-cell weui-cell_active list-active">
<div class="weui-cell__bd">
<input class="weui-input" data-province='${list[i].province}' data-city='${list[i].city}' data-district='${list[i].district}' data-title='${dispose}' value="${list[i].province}${list[i].city}${list[i].district}${dispose}">
</div>
</div>`
}
}
if(strHtml == ''){
element.addClass('hidden');
}else{
element.removeClass('hidden').append(strHtml);
}
},
error:function(error){
console.log("error");
}
});