簡體   English   中英

如何在多邊形下方繪制折線?

[英]How to draw a polyline below a polygon?

如何在Google Maps JavaScript中的多邊形下方繪制折線? 我先繪制多邊形,然后再繪制折線,我不希望線越過多邊形,我希望多邊形成為頂層。

我這樣創建多邊形和折線:

new google.maps.Polyline({
                path: googleCoordinates,
                geodesic: true,
                strokeColor: '#40FF00',
                strokeOpacity: 0.5,
                strokeWeight: 2
            });

new google.maps.Polygon({
                path: googleCoordinates,
                geodesic: true,
                strokeColor: '#FF0000',
                strokeOpacity: 0.5,
                strokeWeight: 2
            });

https://developers.google.com/maps/documentation/javascript/reference?csw=1#PolylineOptions https://developers.google.com/maps/documentation/javascript/reference?csw=1#PolygonOptions

折線和多邊形都具有zIndex屬性,我想這就是您要尋找的:

new google.maps.Polyline({
            path: googleCoordinates,
            geodesic: true,
            strokeColor: '#40FF00',
            strokeOpacity: 0.5,
            strokeWeight: 2,
            zIndex: 10
        });

new google.maps.Polygon({
            path: googleCoordinates,
            geodesic: true,
            strokeColor: '#FF0000',
            strokeOpacity: 0.5,
            strokeWeight: 2,
            zIndex: 11
        });

在此示例中,我將它們設置為10和11,您將不得不處理這些值,因為我不知道它們是否僅限於地圖(我認為是這樣),否則它們會影響多邊形和折線的zIndex在整個頁面中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM