2009-07-08 4 views
2

웹 페이지의 Google지도에서 대중 교통 레이어를 활성화하려면 어떻게해야하나요? 지도는 검색 컨트롤을 사용하여 만듭니다.내장 된 Google SearchControl지도의 대중 교통 레이어

<!-- ++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++ --> 

답변

2

현재 Transit 레이어는 API를 통해 사용할 수 없습니다. 이 문제에 대해 Enhancement Request이 열려 있습니다.

var tileLayerOverlay = new GTileLayerOverlay(
    new GTileLayer(null, null, null, { 
    tileUrlTemplate: 'http://example.com/transit_tiles/{Z}_{X}_{Y}.png', 
    isPng:true, 
    opacity:1, 
    }) 
); 

map.addOverlay(tileLayerOverlay); 

을하지만 교통 타일의 자신의 세트를 렌더링 한 필요 거라고 할 :

1

Google Maps API는 thusly 히,지도에 당신에게 add a tile overlay을 드릴 것입니다.

부수적으로는, 구글이 자신의 운송 층에 사용하는 타일이 유사한 기법을 통해 검색됩니다 : 그래서

http://mlt2.google.com/mapslt?lyrs=transit&x=1310&y=3166&z=13&w=256&h=256&gl=us&hl=en

, 당신이 할 수 있습니다 :

var gTransitTileUrlTemplate = 'http://mlt1.google.com/mapslt?lyrs=transit&x={X}&y={Y}&z={Z}&w=256&h=256&gl=us&hl=en'; 

그러나,이 위반 Maps API의 서비스 약관을 준수해야하며 Google이이 URL을 변경하지 않고 귀하의 애플리케이션을 해할 것이라는 보장은 없습니다.

관련 문제