<input type="text" class="form_input" id="address_input" placeholder="请输入地址">
<div id="address_select"></div>
$(document).on("click", ".select_address_", function(){
var c =$(this).html();
// $("#l2").val($(this).attr('data_lng'));
// $("#j2").val($(this).attr('data_lat'));
// $("#endaddress2").val($(this).html());
// $(".success").css("display","none");
// $(".index_section").css("display","block");
// $(".index_body").css("display","block");
// $(".footer").css("display","block");
console.log(c);
$("#address_input").val(c);
$(".select_address_").css("display","none");
});
$(function () {
// 地图选点还是手动输入
// $(".map_tap").click(function(){
// $("#xuandian").show();
// $("#shuru").hide();
// });
// $(".hand_type").click(function(){
// $("#xuandian").hide();
// $("#shuru").show();
// $("#map_dis").css('display','none');
// });
$('#address_input').bind('input propertychange', function() {
// 百度地图API功能
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point($("#l1").val(),$("#j1").val()), 12);
var options = {
onSearchComplete: function(results){
// 判断状态是否正确
if (local.getStatus() == BMAP_STATUS_SUCCESS){
var html = '';
for (var i = 0; i < results.getCurrentNumPois(); i ++){
html +='<div class="form_phone">';
html+='<span style="cursor: pointer;" '+' data_lng="'+results.getPoi(i).point.lng+'"'+' data_lat="'+results.getPoi(i).point.lat+'"'+' class="select_address_">'+results.getPoi(i).title+'</span>';
html +='</div>';
//console.log(results.getPoi(i));
$("#address_select").html('');
$("#address_select").append(html);
}
}
}
};
var local = new BMap.LocalSearch(map, options);
local.search($(this).val());
});
});