google-maps - 嵌入式 Google SearchControl map 中的交通图层

标签 google-maps google-search-api

如何在网页上的 Google map 中激活公交图层? map 是使用搜索控件创建的。

<!-- ++Begin Map Search Control Wizard Generated Code++ -->
  <!--
  // Created with a Google AJAX Search Wizard
  // http://code.google.com/apis/ajaxsearch/wizards.html
  -->

  <!--
  // The Following div element will end up holding the map search control.
  // You can place this anywhere on your page
-->
  <div id="mapsearch">
    <span style="color:#676767;font-size:11px;margin:1px;padding:0px;">Loading map ...</span>
  </div>

  <!-- Maps Api, Ajax Search Api and Stylesheet
  // Note: If you are already using the Maps API then do not include it again
  //       If you are already using the AJAX Search API, then do not include it
  //       or its stylesheet again
  //
  // The Key Embedded in the following script tags is designed to work with
  // the following site:
  -->
  <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAxMICTqJZCQhVvaG5Z6vcbBQsQZTeCW4bnSEJHaQGIFLLp_Ev4hQzmbQjyOZxyLLe8CmaFaW5G3RI8g"
    type="text/javascript"></script>
  <script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-msw&key=ABQIAAAAxMICTqJZCQhVvaG5Z6vcbBQsQZTeCW4bnSEJHaQGIFLLp_Ev4hQzmbQjyOZxyLLe8CmaFaW5G3RI8g"
    type="text/javascript"></script>
  <style type="text/css">
    @import url("http://www.google.com/uds/css/gsearch.css");
  </style>

  <!-- Map Search Control and Stylesheet -->
  <script type="text/javascript">
    window._uds_msw_donotrepair = true;
  </script>
  <script src="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.js?mode=new"
    type="text/javascript"></script>
  <style type="text/css">
    @import url("http://www.google.com/uds/solutions/mapsearch/gsmapsearch.css");
  </style>

  <style type="text/css">
    .gsmsc-mapDiv {
      height : 400px;
    }

    .gsmsc-idleMapDiv {
      height : 400px;
    }

    #mapsearch {
      width : 700px;
      margin: 1px;
      padding: 0px;
    }
  </style>
  <script type="text/javascript">
    function LoadMapSearchControl() {

      var options = {
            zoomControl : GSmapSearchControl.ZOOM_CONTROL_ENABLE_ALL,
            title : "<?php echo $city. ','. $country; ?>",
            url : "",
            idleMapZoom : GSmapSearchControl.ACTIVE_MAP_ZOOM+1,
            activeMapZoom : GSmapSearchControl.ACTIVE_MAP_ZOOM+1
            }

      new GSmapSearchControl(
            document.getElementById("mapsearch"),
            "<?php echo $city. ','. $country; ?>",
            options
            );
    }
    // arrange for this function to be called during body.onload
    // event processing
    GSearch.setOnLoadCallback(LoadMapSearchControl);
  </script>
<!-- ++End Map Search Control Wizard Generated Code++ -->

最佳答案

目前无法通过 API 使用 Transit 层。有一个Enhancement Request针对此问题开放。

关于google-maps - 嵌入式 Google SearchControl map 中的交通图层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1100858/

相关文章:

google-cloud-platform - Google Search Console API 未返回任何数据

ios - Google Maps myLocationButton 在 Tab Bar Controller Swift 3 下

javascript - 谷歌地图物化选项卡下的 map

google-maps - Google Map API v3 颜色自定义

google-oauth - 带有 Google 自定义搜索功能的 Google 附加链接搜索框

google-api - Google 自定义搜索引擎的自定义 CSS

google-maps - 如何以编程方式与 Google map 分享我的旅行?

android - 如何使用 android api V2 在 GoogleMap 上绘制数千个正方形

google-api - 是否有 "People also ask"的谷歌 API?

php - 如何使用 api 获取所有谷歌搜索结果