Mobile:020-39184565 / 020-84805649
Tel:+86 18122102660
E-mail:lzlao@bdvending.com
Fax:+86 20 39184727
Company Address:C11,HuaChuang Animation Industrial Park,Panyu,GuangZhou,China
//創(chuàng)建和初始化地圖函數(shù):
function initMap(){
createMap();//創(chuàng)建地圖
setMapEvent();//設(shè)置地圖事件
addMapControl();//向地圖添加控件
addMarker();//向地圖中添加marker
}
//創(chuàng)建地圖函數(shù):
function createMap(){
var map = new BMap.Map("dituContent");//在百度地圖容器中創(chuàng)建一個地圖
var point = new BMap.Point(113.428182, 22.995945); //定義一個中心點坐標(biāo)
map.centerAndZoom(point,18);//設(shè)定地圖的中心點和坐標(biāo)并將地圖顯示在地圖容器中
window.map = map;//將map變量存儲在全局
}
//地圖事件設(shè)置函數(shù):
function setMapEvent(){
map.enableDragging();//啟用地圖拖拽事件,默認(rèn)啟用(可不寫)
map.enableScrollWheelZoom();//啟用地圖滾輪放大縮小
map.enableDoubleClickZoom();//啟用鼠標(biāo)雙擊放大,默認(rèn)啟用(可不寫)
map.enableKeyboard();//啟用鍵盤上下左右鍵移動地圖
}
//地圖控件添加函數(shù):
function addMapControl(){
//向地圖中添加縮放控件
var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
map.addControl(ctrl_nav);
//向地圖中添加縮略圖控件
var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
map.addControl(ctrl_ove);
//向地圖中添加比例尺控件
var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
map.addControl(ctrl_sca);
}
//標(biāo)注點數(shù)組
var markerArr = [{ title: "Guangzhou Baoda Intelligent Technology Co., Ltd", content: "Company Address:
C11,HuaChuang Animation Industrial Park,Panyu,GuangZhou,China
Tel:+86 18122102660", point: "113.428182|22.995945", isOpen: 1, icon: { w: 21, h: 21, l: 0, t: 0, x: 6, lb: 5} }
];
//創(chuàng)建marker
function addMarker(){
for(var i=0;i