私はOpenLayersをしてJavaScriptに非常に新しいです、と私は次のような問題があります。openlayersでポリゴンの座標を設定する方法は?
私はOpenLayersをを使用してマップ上に視覚化したい点の座標を表す.csv
テーブルを持っています。私はOpenLayersをページ上の次の例を発見した
、
https://openlayers.org/en/latest/examples/polygon-styles.html
しかし、私はそこの座標の表現を理解できませんでした。具体的には、私は、例えば[-5e6, 6e6]
座標にe
はどういう意味かわかりませんでした。
しかし、私は自分の座標を使用して、私のマップ上の単純な四角形をプロットしてみましたが、それは単に以下のように、地図の中心で、私にポイントを与える:だから
https://jsfiddle.net/api/post/library/pure/#&togetherjs=bD5bfPm7vz
Iドン正確に何が間違っているのか分からず、私は何を変えるべきですか?私は座標が書かれているすべての方法だと思うが、確かではない。
そして、これは私のコードです:
var styles = [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 3
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'orange'
})
}),
geometry: function(feature) {
// return the coordinates of the first ring of the polygon
var coordinates = feature.getGeometry().getCoordinates()[0];
return new ol.geom.MultiPoint(coordinates);
}
})
];
var geojsonObject = {
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {
'name': 'EPSG:3857'
}
},
'features': [{
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
[-3e6, 6e6], [-5e6, 6e6]]]
}
}]
};
var source = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)
});
var layer = new ol.layer.Vector({
source: source,
style: styles
});
var basic = new ol.layer.Tile({
source: new ol.source.OSM()
});
var map = new ol.Map({
layers: [basic, layer],
target: 'map',
view: new ol.View({
center: [0, 3000000],
zoom: 2
})
});