<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ include file="/system/include.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你的密钥"></script>
<title>批量转换</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
var points=[];
var map=null;
$(function(){
$.ajax({
type: "post",
url: "${ctx}/personDesk.do?method=getAddressPonit",
dataType: "text",
async:false,
success:function(data)
{
points=eval(data);
//创建地图
map= new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(103.679396,30.636482), 13); // 设置中心点
map.centerAndZoom( "崇州");
map.setCurrentCity("崇州"); //设置为崇州
map.addControl(new BMap.MapTypeControl());
map.enableScrollWheelZoom(true);
addMarker(points);
}
})
})
//创建标注点并添加到地图中
function addMarker(points) {
//循环建立标注点
for(var i=0, pointsLen = points.length; i<pointsLen; i++) {
var point = new BMap.Point(points[i].LNG, points[i].LAT); //将标注点转化成地图上的点
var marker = new BMap.Marker(point); //将点转化成标注点
map.addOverlay(marker); //将标注点添加到地图上
//添加监听事件
(function() {
var thePoint = points[i];
marker.addEventListener("click",
function() {
showInfo(this,thePoint);
});
})();
}
}
function showInfo(thisMarker,point) {
//获取点的信息
var sContent =
'<ul style="margin:0 0 5px 0;padding:0.2em 0">'
+'<li style="line-height: 26px;font-size: 15px;">'
+'<span style="width: 50px;display: inline-block;">进度:</span>' + point.STATUS + '</li>'
+'<li style="line-height: 26px;font-size: 15px;">'
+'<span style="width: 50px;display: inline-block;">项目:</span>' + point.PRJ_NAME + '</li>'
+'<li style="line-height: 26px;font-size: 15px;"><span style="width: 50px;display: inline-block;">查看:</span><a href="#" onclick=huaxiang("'+point.PRJ_ID+'","'+point.PRJ_NAME+'","'+point.PRJ_JS_ID+'","'+point.PRJ_GC_ID+'")>详情</a></li>'
+'</ul>';
var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
}
function huaxiang(prj_id,name,prj_js_id,prj_gc_id)
{
//window.location="/czAudit/itemPortrait.do?method=detailPage1&prj_id="+rowData.prj_js_id;
parent.parent.parent.addTabs(prj_id,name,"","itemPortrait.do?method=detailPage1&prj_js_id="+prj_js_id+"&prj_gc_id="+prj_gc_id+"&prj_id="+prj_id);
}
</script>
json 数据格式。我的像这样子的