// 定义一个控件类,即function
function SearchControl() {
// 设置默认停靠位置和偏移量
this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
this.defaultOffset = new BMap.Size(-10, 10);
}
//通过JavaScript的prototype属性继承于BMap.Control
SearchControl.prototype = new BMap.Control();
//自定义控件必须实现initialize方法,并且将控件的DOM元素返回
//在本方法中创建个div元素作为控件的容器,并将其添加到地图容器中
SearchControl.prototype.initialize = function (map) {
//创建一个DOM元素
var div = document.createElement("div");
div.id = "searchDiv";
div.style.marginLeft = "3%";
//getUserNum(div,"org",2);
var dt = $(
'' +
''
);
dt.appendTo(div);
map.getContainer().appendChild(div);
return div;
}
// 轨迹查询
function query(type) {
if (type == 1) {
var keyWord = $("#keyWord").val();
search(keyWord);
} else {
$("#keyWord").val('');
search(null);
}
}