zoukankan      html  css  js  c++  java
  • Google Maps API

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=zh-tw"></script>
      <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
       <script type="text/javascript">
           $(function () {
               function showInfo(address, title) {
                   var myOptions = {
                       zoom: 11,
                       center: new google.maps.LatLng(22.2, 113.5),
                       mapTypeId: google.maps.MapTypeId.ROADMAP
                   };
                   var map = new google.maps.Map(document.getElementById("mainMapLayer"), myOptions);
    
                   $.getJSON("GMapInfoHandler.ashx?address=" + escape(address) + "&title=" + escape(title), function (data) {
    
                       $("#list").append("<ul>");
                       $.each(data, function (i) {
                           var marker = new google.maps.Marker({
                               position: new google.maps.LatLng(data[i].Lat, data[i].Lng),
                               animation: google.maps.Animation.DROP,
                               map: map,
                               title: data[i].Title + "-" + data[i].Address
                           });
    
                           $.get("ReportContent.aspx?address=" + escape(data[i].Address) + "&title=" + escape(data[i].Title), function (data) {
                               var infowindow = new google.maps.InfoWindow({
                                   content: data
                               });
    
                               google.maps.event.addListener(marker, 'click', function () {
                                   infowindow.open(map, marker);
                               });
    
                               $("#list").append("<li id=\"list" + i + "\">" + marker.title + "</li>");
                               $("#list" + i).click(function () { infowindow.open(map, marker); });
                           })
                       });
                       $("#list").append("</ul>");
    
                   });
    
               }
    
               showInfo("", "");
    
               $("#btnFind").click(function () {
                   var address = $("#txtAddress").val();
                   var title = $("#txtTitle").val();
                   showInfo(address, title);
               });
           })
      </script>
        <style type="text/css">
            .info{font-family:Consolas;font-size:12px;height:100px;}
            li{font-family:Consolas;font-size:14px;border:1px solid blue;width:120px;margin:2px;cursor:hand;}
            div #mainMapLayer,#list{float:left;}
        </style>
     </head>
     <body>
         <div>
             <label>名稱*:</label>
             <input id="txtTitle"/>
             <label>地址:</label>
             <input id="txtAddress"/>
             <input type="button" id="btnFind" value="查找"/>
         </div>
         <div id="list"></div>
         <div style="padding-top:13px;">
             <div id="mainMapLayer" style="height: 530px;  1200px;">
             </div>
         </div>
     </body>
    </html>

    Ref:

    Google Maps Javascript API V3 Reference

    Examples

  • 相关阅读:
    wget时http无效问题
    mysql8.0.15的最简单安装
    创建时间时jdbcType使用的准确性
    fastJson的几种转换模式
    (mybatis)EnumTypeHandler和EnumOrdinalTypeHandler的区别
    在文件上传时fileName.endsWith()的获取后悔
    day22
    day21
    day20
    day19
  • 原文地址:https://www.cnblogs.com/ncore/p/2875382.html
Copyright © 2011-2022 走看看