//地图盒子的高度
var windheight=$(window).height();
var navheight=$('.y_puicdh_c').height();
$('.map_details').css({'height':(windheight-navheight)+'px'});

//variable = {lat, lng, zoom, zbar, link, title, message}
var map, old, point, marker, undefined, variable = {};
var parser = /[#&]([^=]+)(?:=([^&]*))?/g;
while(query = parser.exec(location.hash)){
    variable[query[1]] = decodeURIComponent(query[2]);
}
document.title = (variable.title ? variable.title + '\u7684' : '') + '\u5730\u7406\u4f4d\u7f6e';
if(typeof $cms_abs == 'undefined')window.$cms_abs = '../';
var canvas = document.getElementById("Mapdetails");
old = variable.lat != undefined && variable.lng != undefined;
point = old ? new BMap.Point(variable.lng,variable.lat) : new BMap.Point(113.33127548857,23.143680171285);

map = new BMap.Map(canvas,{
    maptype:BMAP_PERSPECTIVE_MAP,
    minZoom:3,
    maxZoom:19
});
map.enableScrollWheelZoom();
map.centerAndZoom(point,variable.zoom && variable.zoom.match(/^[3-9]$|^1\d$/) ? parseInt(variable.zoom) : 13);
map.addControl(new BMap.MapTypeControl({type:BMAP_MAPTYPE_CONTROL_DROPDOWN,mapTypes:[BMAP_NORMAL_MAP ,BMAP_SATELLITE_MAP]}));
map.addControl(new BMap.NavigationControl());
if(old){
    marker = new BMap.Marker(point,{title : variable.title ? variable.title : ''});
    map.addOverlay(marker);
    marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
    // var label = new BMap.Label(variable.title,{offset:new BMap.Size(20,-10)});
    // marker.setLabel(label);
    variable.link && marker.addEventListener('click', function(){window.open(variable.link == '_self' ? location.href.replace(/[?#&]link=_self\b/g, '') : variable.link)});

}

if(variable.message){
    var infowindow = new BMap.InfoWindow(variable.message,{
        title : variable.title ? variable.title : ''
    });
    marker.addEventListener('click', function(){map.openInfoWindow(infowindow,point);});
    map.openInfoWindow(infowindow,point);
}