2 Star 11 Fork 3

emu/looking4help

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
layer.js 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
emu 提交于 2020-02-29 17:22 . update layer.js.
function layerControl(){
this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
this.defaultOffset = new BMap.Size(15, 197);
}
layerControl.prototype = new BMap.Control();
layerControl.prototype.initialize = function(map){
var i = new Image();
i.src="layer32.png";
i.onclick=showLayers;
map.getContainer().appendChild(i);
return i;
}
var layerCtrl = new layerControl();
map.addControl(layerCtrl);
function layerSelector(){
this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
this.defaultOffset = new BMap.Size(50, 0);
}
layerSelector.prototype = new BMap.Control();
var layers={
//xinye:"新叶",leihuo:"雷火",
pregnant:"孕妇",children:"小孩",cure:"收治",definite:"确诊",
helped:"已救助",suspected:"高度疑似",possible:"无法排除",contact:"有接触",passaway:"逝者",all:"全部"}
layerSelector.prototype.initialize = function(map){
var d = document.createElement("DIV");
var html=[]
html.push("<form onchange=layerchange(layer.value)><table>");
for(var t in layers){
if(t!="invalidaddress"){
html.push("<tr><td><input type=radio name=layer id=l_"+t+" value="+t+"><label for=l_"+t+" style='color:"+caseTypes[t].color+"'>"+layers[t]+"</label></td></tr>")
}
}
if(layers["invalidaddress"])html.push("<tr><td>地址不详:"+layers["invalidaddress"]+"</td></tr>")
html.push("</table></form>");
d.innerHTML = html.join("");
with(d.style){
border="1px solid gray";
backgroundColor="#eeeeee"
whiteSpace="nowrap"
fontSize="medium"
left="40px";
}
map.getContainer().appendChild(d);
return d;
}
function showLayers(){
var s = layerSltr
var c = layerCtrl;
if(s.isVisible()){
s.hide()
}else{
s.show()
s.setOffset(new BMap.Size(c.getOffset().width+60,
c.getOffset().height>150?c.getOffset().height-150:0))
}
}
var currentLayer="all"
var layerSltr;
function layerchange(type){
if(!layerSltr){
layerSltr = new layerSelector();
map.addControl(layerSltr);
layerSltr.hide();
}
if(!type) type=currentLayer;
drawMapv(type)
currentLayer=type;
layerSltr.hide();
var t=12;
if(document.getElementsByClassName("BMap_stdMpCtrl").length>0){
t=document.getElementsByClassName("BMap_stdMpCtrl")[0].offsetHeight+12;
}
layerCtrl.setOffset(new BMap.Size(15, t))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/stonelf/looking4help.git
git@gitee.com:stonelf/looking4help.git
stonelf
looking4help
looking4help
master

搜索帮助