我有一组(经度,纬度)点组成的多边形,我想要绘制它:
var maxPoint = [36.283, -114.368];
var geoSquare = [ minPoint, [minPoint[0], maxPoint[1]], maxPoint, [maxPoint[0], minPoint[1]]];
var polygonFeature = new Feature(
new Polygon(geoSquare));
我正在以下列方式绘制地图:
var map = new Map({
interactions: defaultInteractions().extend([new Drag()]),
layers: [
new TileLayer({
source: new TileJSON({
url: 'https://maps.siemens.com/styles/osm-bright.json'
})
}),
new VectorLayer({
source: new VectorSource({
features: [polygonFeature]
}),
style: new Style({
stroke: new Stroke({
width: 3,
color: [255, 0, 0, 1]
}),
fill: new Fill({
color: [0, 0, 255, 0.6]
})
})
})
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});
这个多边形位于南加利福尼亚附近,但我在地图上完全看不到正方形。怎么回事??
编辑
这里是一个jsfiddle