jyyhq/witDisplay/js/video/map/SearchControl.js

37 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 定义一个控件类即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 = $(
'<input id="keyWord" placeholder="请输入关键字" type="text" name="workSence" style="height: 30px;background-color: #035FA6;opacity:0.6;border: 1px solid #0347C7;color:#ffffff; margin: 0px;">' +
'<input type="button" value="查询"style="width: 55px;height: 35px;opacity:0.6;background-color: #035FA6;border: 1px solid #0347C7;color:#fff;cursor: pointer;" onclick="query(1)"/>'
);
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);
}
}