1:首先最简单的方法是直接上百度的网站上,使用地图生成器就可以产生了,详细的操作可以参考:http://api.map.baidu.com/lbsapi/creatmap/index.html,在选定了地点后直接点击获取代码就可以得到一个html的代码,然后将其嵌入到web项目中。
2:一下则是我导出的百度地图的代码,有少许修改:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="百度地图,百度地图API,百度地图自定义工具,百度地图所见即所得工具" />
<meta name="description" content="百度地图API自定义地图,帮助用户在可视化操作下生成百度地图" />
<title>百度地图API自定义地图</title>
<!--引用百度地图API-->
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
.iw_poi_title {
color: #CC5522;
font-size: 14px;
font-weight: bold;
overflow: hidden;
padding-right: 13px;
white-space: nowrap
}
.iw_poi_content {
font: 12px arial, sans-serif;
overflow: visible;
padding-top: 4px;
white-space: -moz-pre-wrap;
word-wrap: break-word
}
#dituContent{
width: 100%;
height: 50em;
border: #ccc solid 1px;
}
@media screen and (min-width: 100px) and (max-width: 1020px) {
#dituContent{
width:100%;
height:400px;
}
}
</style>
<script type="text/javascript"
src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
</head>
<body>
<!--百度地图容器-->
<div id="dituContent">
</div>
</body>
<script type="text/javascript">
//创建和初始化地图函数:
function initMap() {
createMap();//创建地图