2013-05-20 40 views
0

請協助。我搜索並經歷了堆棧溢出,但無法在任何地方找到這些信息。有沒有辦法只顯示一個特定的大陸,在我的情況下是非洲,並在谷歌地圖中隱藏所有其他不需要的大陸。這些地圖不應該顯示。我碰到過這篇文章 - >Can i hide land masses with Google Maps API谷歌地圖api 3 - 只顯示特定的大洲

但是沒有具體的例子。

我使用谷歌地圖API 3.

目前我有:

<script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?key=mykey&sensor=true"> 
     </script> 
     <script type="text/javascript"> 
      function initialize() { 

       //Implement map styling 
       var styles = [ 
        { 
         "stylers": [ 
          {"visibility": "simplified"} 
         ] 
        } 
       ]; 


       var styledMap = new google.maps.StyledMapType(styles, {name: "MyMap"}); 

       var mapOptions = { 
        center: new google.maps.LatLng(0.972198, 23.994141), 
        zoom: 3, 
        mapTypeId: google.maps.MapTypeId.ROADMAP, 
        panControl: false, 
        zoomControl: false, 
        streetViewControl: false, 
        mapTypeControl: false, 
        mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style'], 
        draggable: false, 
        scrollwheel: false, 
        panControl: false 

       }; 


       var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); 

       //Load kml of africa 
       var kmlMap = new google.maps.KmlLayer('http://myOverLay.kmz', 
         { 
          //suppressInfoWindows: false, 
          //map: map, 
          preserveViewport: true 
         }); 
       kmlMap.setMap(map); 

       //map.mapTypes.set(); 

       //Associate the styled map with the MapTypeId and set it to display. 
       map.mapTypes.set('map_style', styledMap); 
       map.setMapTypeId('map_style'); 

      } 


      google.maps.event.addDomListener(window, 'load', initialize); 
     </script> 

回答

0

一個選項:

  1. 覆蓋了整個地球,除了在您選擇的大陸孔。 example of concept (US state of Virginia)
  2. 限制縮放和邊界以防止地圖距離顯示該大陸太遠。 description of how to limit the viewable area
+0

如果我現有的KML概述了我的大陸,我是否可以自動翻轉或是否需要手動重新創建KML? @geocodezip –

+0

這取決於你如何顯示它。您在多邊形中創建「洞」的方式是您將外部多邊形(整個世界)纏繞在內部多邊形(您的大陸)的相反方向上。您可以嘗試一下,看看它是否有效,如果它不起作用,則首先反轉外部多邊形的卷繞方向。 – geocodezip

0

似乎不可能。結束使用圖像mapster