2015-10-20 28 views
-2

多邊形孔爲什麼不起作用?多邊形孔(環)不起作用

JSFiddle link

代碼段(從小提琴):

var map; 
 

 
(function() { 
 

 
    map = new google.maps.Map(document.getElementById('map'), { 
 
    center: { 
 
     lat: -23.6569389, 
 
     lng: -46.5297752 
 
    }, 
 
    zoom: 15, 
 
    }); 
 

 

 
    var paths = [ 
 
    [ 
 
     new google.maps.LatLng(-23.644288322408464, -46.52812957763672), 
 
     new google.maps.LatLng(-23.65368372747241, -46.5476131439209), 
 
     new google.maps.LatLng(-23.6694460501439, -46.54031753540039), 
 
     new google.maps.LatLng(-23.669563965596268, -46.5146541595459), 
 
     new google.maps.LatLng(-23.65372303737324, -46.50959014892578) 
 
    ], 
 
    [ 
 
     new google.maps.LatLng(-23.656828482209104, -46.53083324432373), 
 
     new google.maps.LatLng(-23.658754607146985, -46.53306484222412), 
 
     new google.maps.LatLng(-23.658911840583425, -46.528472900390625) 
 
    ] 
 
    ] 
 

 
    var shape = new google.maps.Polygon({ 
 
    map: map, 
 
    paths: paths 
 
    }); 
 

 
})();
html, 
 
body { 
 
    height: 100%; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
#map { 
 
    height: 100%; 
 
}
<script src="https://maps.googleapis.com/maps/api/js"></script> 
 
<div id="map"></div>

+0

如果您的問題不能沒有下面的鏈接可以理解,那麼它不屬於這裏。 – spender

+0

該stackoverflow給出錯誤。不會讓我發佈代碼snipet或鏈接JsFiddle – Gilsones

回答

1

如果外圈變爲 '順時針',內應該去 '逆時針'。更改內一個:

[    
     new google.maps.LatLng(-23.658911840583425, -46.528472900390625), 
     new google.maps.LatLng(-23.658754607146985, -46.53306484222412), 
     new google.maps.LatLng(-23.656828482209104, -46.53083324432373) 
    ] 

工作演示:https://jsfiddle.net/s1whs53w/1/

+0

我不知道!謝謝! – Gilsones