Nonsense not much said, directly to the code;
Copy Code code as follows:
<script>
var map = new Bmap.map (' Allmap ');
var bcenter = new Bmap.point (116.404,39.915);
Map.centerandzoom (bcenter,11);
Custom controls
function Staticcontrol () {
This.defaultanchor = Bmap_anchor_top_left;
This.defaultoffset = new Bmap.size (10,10);
}
API to inherit control
Staticcontrol.prototype = new Bmap.control ();
Initializing controls
Staticcontrol.prototype.initialize=function (map) {
var div = document.createelement (' div ');
var e1 = document.createelement (' input ');
E1.type = ' button ';
E1.value = ' reset ';
E1.onclick=function () {
Statics ();
}
Div.appendchild (E1);
var e2=document.createelement (' input ');
E2.type = ' button ';
E2.value = ' shrink ';
E2.onclick=function () {
Endstatics ();
}
Div.appendchild (E2);
var E3 = document.createelement ("input");
E3.type = "button";
E3.value = "Enlarge";
E3.onclick = function () {
Setstatics ();
}
Div.appendchild (E3);
Add DOM elements to the map
Map.getcontainer (). appendchild (Div);
Back to Dom
return div;
}
To create a control instance
var Staticsctrl = new Staticcontrol ();
Add to map
Map.addcontrol (Staticsctrl);
function statics () {
Map.centerandzoom (New Bmap.point (116.404, 39.915), 11);
}
function Endstatics () {
Map.setzoom (Map.getzoom ()-2);
}
function Setstatics () {
Map.setzoom (Map.getzoom () +2)
}
</script>
The above code is the individual is using the Baidu map of the custom control, I hope you can enjoy.