百度地图API中类似本地搜索
想实现这样一个效果:输入城市名,关键字,根据关键字能搜到本城市中的结果,并将结果用标注的形式显示出来
设计页面:
前台代码如下,就是没有查询结果,不值什么原因
<script type="text/javascript">
var map = new BMap.Map("allmap");
map.centerAndZoom("河南"); //初始化
map.addControl(new BMap.NavigationControl()); //添加平移缩放控件
map.addControl(new BMap.ScaleControl()); //添加比例尺控件
map.enableScrollWheelZoom(); //启用滚轮放大缩小
<%=point %>
</script>
API?? 百度地图API 本地搜索 百度地图搜索
public string key;
public string point;
public string start;
protected void btnSearch_Click(object sender, EventArgs e)
{
start = txtstarat.Text.Trim();
key = txtKey.Text.Trim();
//point += "var local=new BMap.LocalSearch('" + start + "');";
//point += "local.searchInBounds('" + key + "','" + start + "');";
point += "var map = new BMap.Map('allmap');";
point += "map.centerAndZoom('"+start+"',11);";
point += "var local=new BMap.LocalSearch(map,{";
point += "renderOptions:{map:map}";
point +="});";
point += "local.search('" + key + "');";
}