我正在尝试绘制一个带洞的矩形多边形。我的问题是我无法创建一个覆盖整个世界的多边形。该多边形是倒置的,只选择了一条线而不是整个世界。
以下是我能够做出的最大选择的示例。例如,如果我尝试将0(在线new google.maps.LatLng(-85.1054596961173,0)中)更改为任何其他值,则使用倒置选择。
也许我在这里错过了一些显而易见的东西,但我似乎无法使其正常工作。
以下是我能够做出的最大选择的示例。例如,如果我尝试将0(在线new google.maps.LatLng(-85.1054596961173,0)中)更改为任何其他值,则使用倒置选择。
也许我在这里错过了一些显而易见的东西,但我似乎无法使其正常工作。
function initialize() {
var mapOptions = {
zoom: 1,
center: new google.maps.LatLng(24.886436490787712, -70.2685546875),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var worldCoords = [
new google.maps.LatLng(-85.1054596961173, -180),
new google.maps.LatLng(85.1054596961173, 180),
new google.maps.LatLng(85.1054596961173, 180),
new google.maps.LatLng(-85.1054596961173,0)
];
var EuropeCoords = [
new google.maps.LatLng(29.68224948021748, -23.676965750000022),
new google.maps.LatLng(29.68224948021748, 44.87772174999998),
new google.maps.LatLng(71.82725578445813, 44.87772174999998),
new google.maps.LatLng(71.82725578445813, -23.676965750000022)
];
// Construct the polygon.
poly = new google.maps.Polygon({
paths: [worldCoords,EuropeCoords],
strokeColor: '#000000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#000000',
fillOpacity: 0.35
});
poly.setMap(map);
}
以下是代码的链接: http://jsfiddle.net/xs9fcdf9/4/