123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <%@ page contentType="text/html;charset=UTF-8" %>
- <script>
- $(document).ready(function() {
- $("#search-a").click("click", function() {// 绑定查询按扭
- $.ajax({
- type: "POST",
- url: '${ctx}/plate/plate/gisPostionList',
- data: { userName:$("#userName").val()},
- dataType:'json',
- cache: false,
- success: function(data){
- if(data.total>0) {
- map.clearOverlays(); //清除地图上所有覆盖物
- var list = data.rows;
- //console.log(list);
- //var map = new BMap.Map("container");
- //var point,pos,marker;
- //创建检索信息窗口对象
- //var searchInfoWindow = null;
- var point = new Array(); //存放标注点经纬信息的数组
- var marker = new Array(); //存放标注点对象的数组
- var content = new Array(); //存放提示信息窗口对象的数组
- var searchInfoWindow = new Array(); //存放检索信息窗口对象的数组
- for (index = 0; index < list.length; index++) {
- pos = list[index];
- point[index] = new BMap.Point(Number(pos.lon), Number(pos.lat));
- marker[index] = new BMap.Marker(point[index]);
- content[index] = '<div style="margin:0;line-height:20px;padding:2px;">' +
- '第一书记:'+pos.userName+'<br/>打卡时间:'+pos.updateDate +
- '</div>';
- searchInfoWindow[index] = new BMapLib.SearchInfoWindow(map, content[index], {
- title: '第一书记打卡信息', //标题
- width: 290, //宽度
- height: 105, //高度
- panel: "panel", //检索结果面板
- enableAutoPan: true, //自动平移
- searchTypes: [
- BMAPLIB_TAB_SEARCH, //周边检索
- BMAPLIB_TAB_TO_HERE, //到这里去
- BMAPLIB_TAB_FROM_HERE //从这里出发
- ]
- });
- //添加点击事件
- marker[index].addEventListener("click",
- (function (k) {
- // js 闭包
- return function () {
- //map.centerAndZoom(point[k], 18);
- //marker[k].openInfoWindow(info[k]);
- searchInfoWindow[k].open(marker[k]);
- }
- })(index)
- );
- map.addOverlay(marker[index]); //在地图中添加marker
- if (index == 0) {
- map.setCenter(point[index]); // 由于写了这句,每一个被设置的点都是中心点的过程
- }
- /*point = new BMap.Point(Number(pos.lon), Number(pos.lat));//124.834,45.147);//
- map.centerAndZoom(point, 15);
- marker = new BMap.Marker(point); // 创建标注
- map.addOverlay(marker);
- var content = '<div style="margin:0;line-height:20px;padding:2px;">' +
- '村支书:'+pos.userName+'<br/>上传时间:'+pos.createDate +
- '</div>';
- addClickHandler(content,marker);*/
- }
- }else{
- jp.alert('未查询到GIS轨迹信息!');
- return false;
- }
- }
- });
- });
- $.ajax({
- type: "POST",
- url: '${ctx}/plate/plate/gisPostionList',
- data: {},
- dataType:'json',
- cache: false,
- success: function(data){
- if(data.total>0) {
- var list = data.rows;
- //console.log(list);
- //var map = new BMap.Map("container");
- //var point,pos,marker;
- //创建检索信息窗口对象
- //var searchInfoWindow = null;
- var point = new Array(); //存放标注点经纬信息的数组
- var marker = new Array(); //存放标注点对象的数组
- var content = new Array(); //存放提示信息窗口对象的数组
- var searchInfoWindow = new Array(); //存放检索信息窗口对象的数组
- for (index = 0; index < list.length; index++) {
- pos = list[index];
- point[index] = new BMap.Point(Number(pos.lon), Number(pos.lat));
- marker[index] = new BMap.Marker(point[index]);
- content[index] = '<div style="margin:0;line-height:20px;padding:2px;">' +
- '第一书记:'+pos.userName+'<br/>打卡时间:'+pos.updateDate +
- '</div>';
- searchInfoWindow[index] = new BMapLib.SearchInfoWindow(map, content[index], {
- title: '第一书记打卡信息', //标题
- width: 290, //宽度
- height: 105, //高度
- panel: "panel", //检索结果面板
- enableAutoPan: true, //自动平移
- searchTypes: [
- BMAPLIB_TAB_SEARCH, //周边检索
- BMAPLIB_TAB_TO_HERE, //到这里去
- BMAPLIB_TAB_FROM_HERE //从这里出发
- ]
- });
- //添加点击事件
- marker[index].addEventListener("click",
- (function (k) {
- // js 闭包
- return function () {
- //map.centerAndZoom(point[k], 18);
- //marker[k].openInfoWindow(info[k]);
- searchInfoWindow[k].open(marker[k]);
- }
- })(index)
- );
- map.addOverlay(marker[index]); //在地图中添加marker
- if (index == 0) {
- map.setCenter(point[index]); // 由于写了这句,每一个被设置的点都是中心点的过程
- }
- /*point = new BMap.Point(Number(pos.lon), Number(pos.lat));//124.834,45.147);//
- map.centerAndZoom(point, 15);
- marker = new BMap.Marker(point); // 创建标注
- map.addOverlay(marker);
- var content = '<div style="margin:0;line-height:20px;padding:2px;">' +
- '村支书:'+pos.userName+'<br/>上传时间:'+pos.createDate +
- '</div>';
- addClickHandler(content,marker);*/
- }
- }else{
- jp.alert('未查询到GIS轨迹信息!');
- return false;
- }
- }
- });
- });
- function addClickHandler(content,marker){
- marker.addEventListener("click",function(e){
- openInfo(content,e)
- }
- );
- }
- var opts = {
- width : 250, // 信息窗口宽度
- height: 80, // 信息窗口高度
- title : "信息窗口" , // 信息窗口标题
- enableMessage:true//设置允许信息窗发送短息
- };
- function openInfo(content,e){
- var p = e.target;
- var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
- var infoWindow = new BMap.InfoWindow(content,opts); // 创建信息窗口对象
- map.openInfoWindow(infoWindow,point); //开启信息窗口
- }
- </script>
|