You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
3.2 KiB
HTML

5 years ago
<extend name="Public/base" />
<block name="body" >
<style>.head .logo img { margin-top: 22px; }</style>
<div class="part-box">
<link rel="stylesheet" href="__CSS__/business.css">
<div class="ln_map">
<div style="width:1200px;height:406px;border:#ccc solid 1px;" id="dituContent"></div>
<div class="ln_map_a">
<div>公司地址福建省福州市仓山区城门镇大浦路2号安德大厦A电梯五楼 <span>联系人: 雷女士</span> <span> 联系电话: 13067391751</span> </div>
<div>邮政编码350004</div>
</div>
</div>
<script type="text/javascript" src="https://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
<script type="text/javascript">
//创建和初始化地图函数:
function initMap(){
createMap();//创建地图
setMapEvent();//设置地图事件
addMapControl();//向地图添加控件
addRemark();//向地图中添加文字标注
}
//创建地图函数:
function createMap(){
var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
var point = new BMap.Point(119.36461610058595,26.002382945493657);//定义一个中心点坐标
map.centerAndZoom(point,18);//设定地图的中心点和坐标并将地图显示在地图容器中
window.map = map;//将map变量存储在全局
}
//地图事件设置函数:
function setMapEvent(){
map.enableDragging();//启用地图拖拽事件,默认启用(可不写)
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写)
map.enableKeyboard();//启用键盘上下左右键移动地图
}
//地图控件添加函数:
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);
}
//文字标注数组
var lbPoints = [{point:"119.36461610058595|26.002382945493657",content:"福建省福州市仓山区城门镇大浦路2号安德大厦A电梯五楼"}
];
//向地图中添加文字标注函数
function addRemark(){
for(var i=0;i<lbPoints.length;i++){
var json = lbPoints[i];
var p1 = json.point.split("|")[0];
var p2 = json.point.split("|")[1];
var label = new BMap.Label("<div style='padding:2px;'>"+json.content+"</div>",{point:new BMap.Point(p1,p2),offset:new BMap.Size(3,-6)});
map.addOverlay(label);
label.setStyle({borderColor:"#999"});
}
}
initMap();//创建和初始化地图
</script>
</block>