Sem mais delongas, basta apresentar o código;
A cópia do código é a seguinte:
<Cript>
var map = new bmap.map ('allmap');
var BCenter = new Bmap.point (116.404.39.915);
map.CenteRandzoom (BCenter, 11);
// controle personalizado
função staticcontrol () {
this.DefaultAnchor = bmap_anchor_top_left;
this.defaultOffset = new Bmap.size (10,10);
}
// herdando a API de controle
staticcontrol.prototype = new Bmap.Control ();
// inicialize o controle
staticcontrol.prototype.initialize = function (map) {
var div = document.createElement ('div');
var e1 = document.createElement ('input');
e1.Type = 'Button';
e1.value = 'Redefinir';
e1.OnClick = function () {
STATICS ();
}
Div.AppendChild (E1);
var e2 = document.createElement ('input');
e2.Type = 'Button';
e2.Value = 'Zoom Down';
e2.oClick = function () {
endstatics ();
}
Div.AppendChild (E2);
var e3 = document.createElement ("entrada");
e3.Type = "Button";
e3.Value = "Zoom in";
e3.OnClick = function () {
setStatics ();
}
Div.AppendChild (E3);
// Adicionar elementos dom ao mapa
map.getContainer (). AppendChild (div);
// retorna ao dom
retornar div;
}
// Crie uma instância de controle
VAR STATICSCTRL = new StaticControl ();
// Adicionar ao mapa
map.addControl (STATICSCTRL);
Função STATICS () {
map.CenteRandzoom (New Bmap.Point (116.404, 39.915), 11);
}
function endstatics () {
map.setZoom (map.getzoom ()-2);
}
função setStatics () {
map.setzoom (map.getzoom ()+2)
}
</script>
O código acima é o controle personalizado dos mapas Baidu que estou usando. Espero que todos possam gostar.