高德地图代码,自定义位置和悬浮框内容:
<style type="text/css">
#container{
height: 490px;
margin: 0px;
font: 12px Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial;
}
.info-title{
color: white;
font-size: 14px;
background-color: #5EB92D;
line-height: 26px;
padding: 0px 0 0 6px;
font-weight: lighter;
letter-spacing: 1px
}
.info-content{
padding: 4px;
color: #666666;
line-height: 23px;
}
.info-content img{
float: left;
margin: 3px;
}
</style>
<div id="container" tabindex="0"></div>
<div id='panel'></div>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=df3689a8cc8bbf6fd7a76d05a3333a65"></script>
<script type="text/javascript">
var map = new AMap.Map('container',{
resizeEnable: true,
zoom: 17,
center: [121.274236,31.128635]
});
var marker = new AMap.Marker({
position: [121.274236,31.128635]
});
marker.setMap(map);
marker.on('click',function(e){
infowindow.open(map,e.target.getPosition());
})
AMap.plugin('AMap.InfoWindow',function(){
infowindow = new AMap.InfoWindow({
content: '<div class="info-title">上海XXXXX有限公司</div><div class="info-content">'+
'业务咨询:021-67688852<br />技术咨询:1666666866<br />公司地址:上海市松江区方泗路138号5层<br/>'+
'</div>',
offset: new AMap.Pixel(0, -30)
});
infowindow.open(map,[121.274236,31.128635]);
})
AMap.plugin(['AMap.ToolBar','AMap.Scale'],function(){
var toolBar = new AMap.ToolBar();
var scale = new AMap.Scale();
map.addControl(toolBar);
map.addControl(scale);
})
</script>