zoukankan      html  css  js  c++  java
  • 高德地图在marker里设置自定义属性

    使用js引入高德地图

    <script type="text/javascript"> var map = new AMap.Map('container', { resizeEnable: true, zoom:11, center: [116.397428, 39.90923]//默认的地图中心经纬度 });

    //  在地图上设置marker点
    var markerTemp = new AMap.Marker({
        position : [lng,lat],    //  里面是经纬度
    offset : new AMap.Pixel(-21,-21),//偏移量,默认以marker左上角位置为基准点
    map : map
    });

    //  给marker里设置自定义属性
    markerTemp.id = "123";


    //  给marker添加点击事件,获取获取e对象
      AMap.event.addListener(auto, "select", select);
    function select(e) {
        //  获取存入的id
         console.log(e.target.id);
    var lng = e.poi.location.lng;
    var lat = e.poi.location.lat;
    console.log(e.poi.location.lng);
    if (e.poi && e.poi.location) {
    map.setZoom(15);
    map.setCenter(e.poi.location);
    addMarker(lng,lat);
    }
    }
    </script>


    
    
  • 相关阅读:
    2016.11.21随笔
    2016.11.19随笔
    年月日
    导航position:absolute
    360搜索(边框)
    导航代码position:relative
    邮箱注册代码
    2016.11.18随笔
    2016.11.17随笔
    个人简历网页版代码
  • 原文地址:https://www.cnblogs.com/thesun/p/11690397.html
Copyright © 2011-2022 走看看