더 이상 고민하지 않고 코드를 제시하십시오.
코드 사본은 다음과 같습니다.
<cript>
var map = new bmap.map ( 'AllMap');
var bcenter = new bmap.point (116.404,39.915);
Map.Centerandzoom (Bcenter, 11);
// 사용자 정의 제어
함수 staticcontrol () {
this.defaultanchor = bmap_anchor_top_left;
this.defaultOffset = new bmap.size (10,10);
}
// 제어 API를 상속합니다
staticcontrol.prototype = new BMap.Control ();
// 컨트롤을 초기화합니다
staticcontrol.prototype.initialize = function (map) {
var div = document.createelement ( 'div');
var e1 = document.createElement ( '입력');
e1.type = '버튼';
e1.value = '재설정';
e1.onclick = function () {
정적 ();
}
Div.AppendChild (E1);
var e2 = document.createElement ( '입력');
e2.type = '버튼';
e2.value = 'Zoom Down';
e2.onclick = function () {
endstatics ();
}
Div. AppendChild (E2);
var e3 = document.createElement ( "입력");
e3.type = "버튼";
e3.value = "Zoom In";
e3.onclick = function () {
setstatics ();
}
Div. AppendChild (E3);
// 맵에 DOM 요소를 추가합니다
map.getContainer (). 부록 (div);
// DOM으로 돌아갑니다
반환 div;
}
// 제어 인스턴스를 만듭니다
var staticsctrl = new staticcontrol ();
//지도에 추가합니다
map.addControl (staticsctrl);
함수 stantics () {
Map.Centerandzoom (New Bmap.point (116.404, 39.915), 11);
}
함수 endstatics () {
map.setzoom (map.getzoom () -2);
}
함수 setstatics () {
map.setzoom (map.getzoom ()+2)
}
</스크립트>
위의 코드는 내가 사용중인 Baidu 맵의 맞춤형 제어입니다. 모두가 좋아할 수 있기를 바랍니다.