Hello Forma team
Using the following code I manage to create a squared shaped geoJson and add it as an Element in the Hierarchy
But I haven't found a way to actually remove it (or delete it)
Keep in mind I have already tried using the RenderGeojsonApi for the geoJson and keeping the id for using it in the remove method but this approach is not helpful because I want to allow the user to reposition(dragging) the square via moving it with the mouse.
Basically what would be helpful is to use the element path to remove the element entirely (or the urn)
Thanks for the help!
Giannis
async createSquareSelection() {
const geoJson = this.createGeoJSONSquare({x: 0, y: 0}, 100);
const {id, urn, revision} = await this.formaService.forma.integrateElements.createElementHierarchy({
data: {
rootElement: "root",
elements: {
root: {
id: "root",
properties: {
category: "site_limit",
color: "#C4313D",
geometry: {
type: "Inline",
format: "GeoJSON",
geoJson: geoJson,
},
},
},
},
},
});
const res = await this.formaService.forma.proposal.addElement({
urn,
});
}
Solved! Go to Solution.
Solved by md_amjad_hossain. Go to Solution.
Solved by vilde.barth. Go to Solution.
Hei @iklimis:
Right now, we dont support `removeElement` functionality. But, you can take a look at the `replaceElement` method. That, might satisfy your needs!!
But, I will raise an internal feature request to support the `removeElement`.
Thanks
Hey @md_amjad_hossain thanks for your reply!
Yes a removeElement() would provide a lot of help for this specific issue and for what I can imagine prove very helpful for future development ideas.
I have experimented with replaceElement() but that requires the need to create a mock object (an empty one..) and replacing it instead of just removing the element cleanly.
Regards
Giannis
@iklimis Do I understand correctly that you just want to temporary visualize the polygon? If so, you could use the Render GeoJSON API to preview the square and remove it when you do not want to show it anymore. By using this API, the preview is automatically removed when you close your extension, which is something that would be nice in your use case as well?
Hey@vilde.barth
Already experimented with the render geoJson but in this particular case wasn't convenient because we would like for the user to be able to drag the square around in a position convenient for them.
The render geoJson doesnt allow that functionality.
The main goal is to allow the user to 'preview' the selection before they 'lock' it
Just a side note:
We do have `hideElement` and `unhideElement`, under `render` API, that absolutely could help you with your preview stuff!!
Thanks
Can't find what you're looking for? Ask the community or share your knowledge.