• 最土团购集成google map,marker跟随鼠标移动


    <div id="order-pay-dialog" class="order-pay-dialog-c" style="620px;">
        <h3><span id="order-pay-dialog-close" class="close" onclick="return X.boxClose();">关闭</span>谷歌地图坐标定位</h3>
        <div id="map_canvas" style="620px; height:420px"></div> 
    </div>
    <script>
    var infowindow=null;
    var infowindow2=null;
    var marker =null;
    function initialize() {
      geocoder = new google.maps.Geocoder();
      var myLatlng = new google.maps.LatLng({$longi}, {$lati});
      var myOptions = {
        zoom: 13,
        center: myLatlng,
        navigationControl: false,
        scaleControl: false,
        streetViewControl: false,
        mapTypeControl:false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

      
      google.maps.event.addListener(map, 'click', function(event) {
      X.misc.setgooglemappoint(event.latLng);

    //将标记点移动东到点击的地方 

    marker.setPosition(event.latLng);
      });
    init(map ,myLatlng );
    }

    setTimeout(initialize,100);


    function init(map,myLatlng ) {   
           addSite(map,"",myLatlng,"" );
        }   
      
        function addSite(map, siteDesc, location,address) {     
             marker = new google.maps.Marker({   
             position: location,   
             map: map   
          });   
          attachSecretMessage(marker, siteDesc,address);   
        }   
        function attachSecretMessage(marker, siteDesc,address) {   

        infowindow2=infowindow;
          infowindow = new google.maps.InfoWindow(   
              { //content: '<b>商场名称: </b>' + siteDesc + '</br>'+'<b>商场地址:</b>'+ address +'</br>',   
                content: '<b>A </b>',  
                size: new google.maps.Size(50,50)   
              });   


            google.maps.event.addListener(marker, 'click', function() {   
            infowindow.open(map,marker);   

          });   
        }   

    </script>

  • 相关阅读:
    7. 流程控制
    6. 工作区域与包
    5. Go函数
    4. Go常量
    面试题1
    数据库三范式
    触发器和存储过程
    面试题
    js 程序执行与顺序实现详解 ,来自网上
    基础的优化数据库查询,个人笔记
  • 原文地址:https://www.cnblogs.com/jifeng/p/2690298.html
Copyright © 2020-2023  润新知