高德地图距中心坐标两公里内坐标点标记(springMVC)

<%@page import="java.util.Map"%>
<%@page import="javax.enterprise.inject.Model"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>


<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">


    <title>基本地图展示</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=449eb6e08878209847976b1201d88eed&plugin=AMap.CitySearch"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
     <script src="http://webapi.amap.com/js/marker2.js"></script>
     <script src="${path}/public/js/jquery.min.js"></script>
</head>
 <style type="text/css">
        .info {
            border: solid 1px silver;
        }
        div.info-top {
            position: relative;
            background: none repeat scroll 0 0 #F9F9F9;
            border-bottom: 1px solid #CCC;
            border-radius: 5px 5px 0 0;
        }
        div.info-top div {
            display: inline-block;
            color: #333333;
            font-size: 14px;
            font-weight: bold;
            line-height: 31px;
            padding: 0 10px;
        }
        div.info-top img {
            position: absolute;
            top: 10px;
            right: 10px;
            transition-duration: 0.25s;
        }
        div.info-top img:hover {
            box-shadow: 0px 0px 5px #000;
        }
        div.info-middle {
            font-size: 12px;
            padding: 6px;
            line-height: 20px;
        }
        div.info-bottom {
            height: 0px;
            width: 100%;
            clear: both;
            text-align: center;
        }
        div.info-bottom img {
            position: relative;
            z-index: 104;
        }
        span {
            margin-left: 5px;
            font-size: 11px;
        }
        .info-middle img {
            float: left;
            margin-right: 6px;
        }
    </style>
<body>
<div id="container"></div>
<script>
    var map = new AMap.Map('container', {
        resizeEnable: true,
        zoom:13,
        center: [121.58874500,31.10762200]
    
    });
 
    var marks=[];
    <%
    List map= (List)request.getAttribute("shopslist");
   if(map!=null){
    for(int i=0;i<map.size();i++){
    Map<String,Object> ld=(Map<String,Object>)map.get(i);
     
    %>
     
  
    //添加点标记,并使用自己的icon
    var mark= new AMap.Marker({
        title:<%=ld.get("uuid")%>,
        id:<%=ld.get("uuid")%>,
        position: [<%=ld.get("longitude")%>,<%= ld.get("latitude")%>],
        icon: new AMap.Icon({            
            size: new AMap.Size(40, 50),  //图标大小
            image: "http://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png",
            imageOffset: new AMap.Pixel(0, -60)
        })        
    });
    map.add(mark);  
    marks.push(mark);
   
<%}}%>
for(i=0;i<marks.length;i++){
 
   var marker=marks[i];
   AMap.event.addListener(marker, 'click', function(e){
var uuid=e.target.getTitle();
$.ajax({
       type:"post",
       url:"${path}/app/disbu/detail",
       data:{
  uuid:uuid,
  type:1
      },
       dataType:"json",
           success: function(data){      
          var data=eval(data.datas); 
         
         
        var title=data.shopName;
        content = [];
        content.push(data.province+data.city+data.county+data.community+data.houseNum);
         var infoWindow = new AMap.InfoWindow({
               isCustom: true,  //使用自定义窗体
               content: createInfoWindow(title, content.join("<br/>")),
               offset: new AMap.Pixel(16, -45)
           });
           infoWindow.open(map, e.target.getPosition());
     }
  });

});
}


 
  //实例化信息窗体
   
  var infoWindow = new AMap.InfoWindow({
      isCustom: true,  //使用自定义窗体
      content: createInfoWindow(title, content.join("<br/>")),
      offset: new AMap.Pixel(16, -45)
  });


  //构建自定义信息窗体
  function createInfoWindow(title, content) {
      var info = document.createElement("div");
      info.className = "info";


      //可以通过下面的方式修改自定义窗体的宽高
      //info.style.width = "400px";
      // 定义顶部标题
      var top = document.createElement("div");
      var titleD = document.createElement("div");
      var closeX = document.createElement("img");
      top.className = "info-top";
      titleD.innerHTML = title;
      closeX.src = "http://webapi.amap.com/images/close2.gif";
      closeX.onclick = closeInfoWindow;


      top.appendChild(titleD);
      top.appendChild(closeX);
      info.appendChild(top);


      // 定义中部内容
      var middle = document.createElement("div");
      middle.className = "info-middle";
      middle.style.backgroundColor = 'white';
      middle.innerHTML = content;
      info.appendChild(middle);


      // 定义底部内容
      var bottom = document.createElement("div");
      bottom.className = "info-bottom";
      bottom.style.position = 'relative';
      bottom.style.top = '0px';
      bottom.style.margin = '0 auto';
      var sharp = document.createElement("img");
      sharp.src = "http://webapi.amap.com/images/sharp.png";
      bottom.appendChild(sharp);
      info.appendChild(bottom);
      return info;
  }


  //关闭信息窗体
  function closeInfoWindow() {
      map.clearInfoWindow();
  }


    </script>
</body>
</html>














  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值