【发布时间】:2019-06-05 18:29:05
【问题描述】:
我想在(经度、纬度)点上画一个多边形:
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
【问题讨论】:
-
如果你能提供一个小提琴就好了。
-
@randomSoul 已编辑以包含 jsfiddle