簡體   English   中英

僅在bing map中顯示多邊形區域

[英]show polygon area only in bing map

我在bing map中有多邊形矩形形狀..如何修改代碼以便只顯示多邊​​形內的區域...

這是代碼:

        <script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

        <script type="text/javascript">

            function GetMap()
            {
                // Initialize the map
                var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"At7RkDItXU6kncQzZa8M9lFfMbzPgmulJYLkhYn5JMMZfHL86lNyFZvGWWngxaAP",
                                                 });

                // Create a polygon
                var vertices = new Array(new Microsoft.Maps.Location(20,-20), new Microsoft.Maps.Location(20,20), new Microsoft.Maps.Location(-20,20), new Microsoft.Maps.Location(-20,-20), new Microsoft.Maps.Location(20,-20));
                var polygoncolor = new Microsoft.Maps.Color(100,100,0,100);
                var polygon = new Microsoft.Maps.Polygon(vertices,{fillColor: polygoncolor, strokeColor: polygoncolor});

                // Add the polygon to the map
                map.entities.push(polygon);
            }

            </script>
        </head>
<body onload="GetMap();">
    <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
</body>

它可以被視為控件上的掩碼。

用倒置多邊形掩蔽

該技術包括從當前邊界框創建多邊形,並且將排除特定區域。

當然,這種方法有其局限性,並且在這種情況下很難管理多個高級形狀。

我們的Alastair在這篇博客文章中對此進行了解釋,並且很容易進行調整,因此在使用高級形狀模塊時,所有內容都只在客戶端運行,只有全局多邊形和“洞”:

http://alastaira.wordpress.com/2012/11/28/masking-out-particular-areas-of-interest-on-bing-maps/

Bing地圖由Alastair掩蓋多邊形

自重疊多邊形另一種解決方案是在當前邊界框上創建一個多邊形,以在所有可見區域的頂部繪制全局多邊形,然后添加位置,使多邊形僅在您擁有自己的區域時循環。

默認情況下,融合模式會導致隱藏兩個多邊形的排除,您可以查看SVG中的有用屬性,但它也可以根據瀏覽器進行限制。

我假設你要刪除邊框。 如果是這種情況,請將strokeThickness設置為0,並且不要設置strokeColor

暫無
暫無

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

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