OpenGeoscience / geojs

High-performance visualization and interactive data exploration of scientific and geospatial location aware datasets

Home Page:https://opengeoscience.github.io/geojs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support entering creation mode with a partial shape

subdavis opened this issue · comments

For example, instead of starting creation at the beginning, start with some number of points already placed.

annotationLayer.mode('line', { type: 'LineString', coordinates: [100, 100] })

This would put the annotation layer in creation mode with 1 point already dropped, ready to place the second.

I think this is generally applicable to line, rectangle, and polygon. It should probably throw and error if you try it with a point.

If a maintainer is willing to accept that or a similar API, I could attempt to implement. This would not be a breaking change.

The work around you be to switch to create mode, then immediately modify the currentAnnotation.

if (m_this.currentAnnotation) {
switch (m_this.currentAnnotation.state()) {
case geo_annotation.state.create:
m_this.removeAnnotation(m_this.currentAnnotation);
break;
case geo_annotation.state.edit:
m_this.currentAnnotation.state(geo_annotation.state.done);
m_this.modified();
m_this.draw();
break;

Looks like there are options to try before we make an official attempt.

Currently, the second parameter is an annotation. If we accept an annotation on create, then we could start with that annotation but in create mode rather than edit mode.

If we accept geoJSON there, this would be functionally the same as adding annotations as geojson and using the last such annotation as part of the creation process.