Skip to content

Commit b8c6483

Browse files
committed
fix: Circle
1 parent e94cd7b commit b8c6483

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/GEOComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ var GEOComp = (function () {
156156
"modify:move": true,
157157
"modify:point": true,
158158
"modify:line": true,
159+
"modify:oval": true,
159160
"modify:polygon": true,
160161
"modify:delete": true,
161162
"modify:redo": true,

src/i18n/comps/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const en = {
6464
"modify:move": "Select feature (Modify)",
6565
"modify:point": "Add point (Modify)",
6666
"modify:line": "Add line (Modify)",
67+
"modify:oval": "Add oval (Modify)",
6768
"modify:polygon": "Add polygon (Modify)",
6869
"modify:delete": "Delete feature (Modify)",
6970
"modify:redo": "Redo feature (Modify)",

src/vendors/Geo.jsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Swipe from 'ol-ext/control/Swipe'
3131
import UndoRedo from 'ol-ext/interaction/UndoRedo'
3232
import ModifyFeature from 'ol-ext/interaction/ModifyFeature'
3333
import LayerSwitcher from 'ol-ext/control/LayerSwitcher'
34+
import DrawRegular from 'ol-ext/interaction/DrawRegular'
3435

3536
///Local import
3637
import RotateNorthControl from './RotateNorthControl'
@@ -55,7 +56,6 @@ function Geo(props) {
5556
// Vector layer for drawing
5657
const [drawVector] = useState(new VectorLayer({
5758
name: 'draw',
58-
title: "Drawing",
5959
displayInLayerSwitcher: false,
6060
source: new VectorSource(),
6161
style: geoJsonStyleFunction
@@ -223,7 +223,8 @@ function Geo(props) {
223223
if (!featureEnabled('menu')) mainbar.element.classList.add('nomenu')
224224
if ((featureEnabled('modify')
225225
&& (featureEnabled('modify:move') || featureEnabled('modify:point') || featureEnabled('modify:line')
226-
|| featureEnabled('modify:polygon') || featureEnabled('modify:undo') || featureEnabled('modify:redo')
226+
|| featureEnabled('modify:polygon') || featureEnabled('modify:oval')
227+
|| featureEnabled('modify:undo') || featureEnabled('modify:redo')
227228
|| featureEnabled('modify:delete')))
228229
|| featureEnabled('save')
229230
|| featureEnabled('center'))
@@ -250,7 +251,8 @@ function Geo(props) {
250251
group: false // group controls together
251252
});
252253
if (featureEnabled('modify:move') || featureEnabled('modify:point') || featureEnabled('modify:line')
253-
|| featureEnabled('modify:polygon') || featureEnabled('modify:undo') || featureEnabled('modify:redo')
254+
|| featureEnabled('modify:polygon') || featureEnabled('modify:oval')
255+
|| featureEnabled('modify:undo') || featureEnabled('modify:redo')
254256
|| featureEnabled('modify:delete'))
255257
mainbar.addControl(editbar);
256258

@@ -291,6 +293,24 @@ function Geo(props) {
291293
});
292294
if (featureEnabled('modify:point')) editbar.addControl(pedit);
293295

296+
// Add editing tools
297+
var cedit = new Toggle({
298+
html: '<i class="fa fa-circle" ></i>',
299+
title: 'Oval',
300+
onToggle: (active) => {
301+
olMap.removeInteraction(snap);
302+
olMap.removeInteraction(modify);
303+
},
304+
interaction: new DrawRegular({
305+
source: drawVector.getSource(),
306+
// geometryName: 'geom',
307+
// condition: ol.events.condition.altKeyOnly,
308+
sides: 0,
309+
//canRotate: $("#rotation").prop('checked')
310+
})
311+
});
312+
if (featureEnabled('modify:oval')) editbar.addControl(cedit);
313+
294314
var ledit = new Toggle({
295315
html: '<i class="fa fa-share-alt" ></i>',
296316
title: 'Line',
@@ -597,7 +617,7 @@ function Geo(props) {
597617
olMap.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
598618
// Vector feature click logic
599619
if (!(featureEnabled('modify') &&
600-
(pdelete.getActive() || pmove.getActive() ||
620+
(pdelete.getActive() || pmove.getActive() || cedit.getActive() ||
601621
pedit.getActive() || ledit.getActive() || fedit.getActive()))
602622
&& layer && layer.get("selectable") !== false && feature) { //only fire event if we are not drawing
603623
fireEvent('click:feature', {

0 commit comments

Comments
 (0)