사용자가 세계지도에서 영역을 표시 할 수있는 응용 프로그램을 작성 중입니다. 이제는이 영역이 매우 작아서 확대되지 않을 때 클릭하기가 어렵습니다.스타일이있는 사각형의 최소 크기
스타일 기능에서 (사각형 기능을 항상 렌더링해야 함) 정의 할 수있는 방법이 있습니까? 적어도 예를 들면 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
});
과 표시면에
당신은 몇 가지 관련 코드, 특별히'ol.interaction.Draw'을 보여줄 수 있습니다. –
@JonatasWalker 글쎄, 그림 그리기가 아니라 (세계)지도에 사각형을 표시 할 때가 아닙니다. 베를린 주변에 직사각형을 만들고 나서 그것을 세계지도에 표시한다고 가정 해 봅시다. 거기에 그냥 1px × 1px 크기 (+ 경계의 너비) – levu
하지만 워크 플로가 어떻게됩니까? 어떤 사용자는 직사각형을 만들어 GeoJSON에 저장합니까? –