私はユーザーが世界地図上の領域をマークすることができるアプリケーションを書いています。これらの領域は非常に小さくても構いません。スタイルの長方形の最小サイズ
(スタイル機能などで)どのように(矩形の)フィーチャが常にレンダリングされるべきかを定義する方法はありますか少なくとも、例えば10px×10px?
アップデート:私は現在使用していくつかのコード:
描画側:
vectorSource.addFeature(
new ol.Feature({
geometry: ol.geom.Polygon.fromExtent(app.map.lonlate(extent)),
// … some more custom properties like a display name …
})
);
スタイル機能:
function(feature) {
return [new ol.style.Style({
stroke: new ol.style.Stroke({
color: feature.get('mine') ? '#204a87' : '#729fcf',
width: 2
}),
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, ' + (feature.get('mine') ? '0.5' : '0.2') + ')'
})
})];
}
var draw = new ol.interaction.Draw({
source: vectorSource,
type: 'LineString',
geometryFunction: function(coordinates, geometry) {
if(!geometry) {
geometry = new ol.geom.Polygon(null);
}
var start = coordinates[0];
var end = coordinates[1];
geometry.setCoordinates([[
start,
[start[0], end[1]],
end,
[end[0], start[1]],
start
]]);
return geometry;
},
maxPoints: 2
});
draw.on('drawend', function(e) {
var extent = e.feature.getGeometry().getExtent();
extent = app.map.rlonlate(extent); // own function to convert it from map coordinates into lat/lon
// some code to save the extent to the database
});
と表示側の
:現在の解像度で10ピクセル。 –
@ JonatasWalkerまあ、描画するときではなく、(世界の)地図に四角形を表示するときです。ベルリンの周りに長方形を作成し、それを世界地図に表示してみましょう。そこには1px×1pxのサイズ(+ボーダーの幅)があります – levu
しかし、ワークフローはどうですか?ユーザーが長方形を作成してGeoJSONに保存するユーザーがいますか? –