zoukankan      html  css  js  c++  java
  • 最土团购集成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>

  • 相关阅读:
    C#中页面之间跳转方法比较
    C#中web页面之间传递数组参数
    js跳转传递参数
    枚举
    js操作做GridView
    数据库登录问题汇总
    数据库登录遇到的问题
    关于配置服务器(IIS7)(二)
    关于配置服务器(IIS7)
    使用JavaScript设置、获取父子页面中的值
  • 原文地址:https://www.cnblogs.com/jifeng/p/2690298.html
Copyright © 2011-2022 走看看