Hoppa till huvudinnehållet

clear geometry picker

Kommentarer

3 kommentarer

  • Ryan Kelley

    Did you figure this out already? If not, you can use a Run Command activity and clear the graphics that way. This is what I had to do in order for a graphic they defined a feature with not to show up in the Print product. 

    Command Name: 

    map.clear-markup

    0
  • GIS Support

    Thanks for the suggestion, much appreciated. I should have noted that I'm targeting Web AppBuilder so that's not available to me.

    My users haven't noticed the original graphic that still persists so for now its just a me issue. 

    0
  • Permanently deleted user

    I just got this working on my end, so posting a solution for others (since this showed up on Google early for me). Hope it helps, even if late.

    For your answer in short: You also need to delete the appropriate `state` array value you want to get rid of the map objects. Likely at:
    `$formQueryOptions.state.geometryMapSelection.state`
    (the indexes should match the geometry you are deleting)



    For a ton of info to potentially help others:

    My use case, this can be done by setting properties of your original Geometry Picker [object]. Namely the Geometry Picker [object]'s properties `state` (array values) and `value.geometry` (array values).

    You can remove the relative indexes from both of these arrays to mimic the deletion of a Geometry Picker item. The use case I've needed several times involves logic that determines if the drawn object is good or not. I normally want to automatically delete this drawing instead of depending on the user understanding they need to do it. For me this is always the most recently drawn object (or the last indexes), but the same principle can be applied to delete whichever points you want.

    Below is an example of the values you care about. In this console I have 3 points. (the `state` array has a fourth value that is used for the next point to be drawn from my understanding):

    Unfortunately, I don't have any sandbox I can share VertiGIS tools/components/logic with. I have a .json file that has some of the basic logic I use to grab the above values, delete the last drawn point values, then reapply to the original Geometry object effectively deleting the unwanted drawn points automatically. It has notes that hopefully help explain what it is doing. Since I can't upload or share logic I have the .json code in the below block:

    {"_properties":{"isServerWorkflow":false},"components":[{"id":2,"steps":[{"id":3,"inputs":{},"position":"0,0","purpose":"start","title":"Start","transitions":[{"id":7,"position":"90,60 90,90","sourceConnector":"bottom","target":{"id":4},"targetConnector":"top"}]},{"action":"gcx:wf:forms:form:DisplayForm","id":4,"inputs":{"form":{"accessors":[],"code":"resources.forms[values.id]","values":{"id":5}}},"name":"form1","position":"-30,90","title":"Display Form"}]},{"id":8,"steps":[{"id":9,"inputs":{},"position":"0,0","purpose":"start","title":"Event","transitions":[{"id":38,"position":"90,60 90,90","sourceConnector":"bottom","target":{"id":25},"targetConnector":"top"}]},{"action":"gcx:wf:core::SetProperty","description":"The original **`geometry`** array is replace with the above spliced array, removing the bad point that was just drawn.","id":13,"inputs":{"object":{"accessors":["$valueGeometryPickerObject"],"annotations":[{"count":26,"index":0,"kind":"idref"}],"code":"$valueGeometryPickerObject.result.value","source":"$valueGeometryPickerObject.result.value"},"propertyName":"geometry","propertyValue":{"accessors":["$valueGeometryPickerGeometryArray"],"annotations":[{"count":33,"index":0,"kind":"idref"}],"code":"$valueGeometryPickerGeometryArray.result","source":"$valueGeometryPickerGeometryArray.result"}},"position":"120,980","title":"Set Property"},{"action":"gcx:wf:core::CreateValue","description":"Gets all the items in the **`geometry`** properties of the Geometry Picker [object] except the last one (assumed unwanted from the above **`if`** logic).","id":15,"inputs":{"expression":{"accessors":["$valueGeometryPickerObject"],"annotations":[{"count":26,"index":0,"kind":"idref"}],"code":"$valueGeometryPickerObject.result.value.geometry.slice(0, -1)","source":"$valueGeometryPickerObject.result.value.geometry.slice(0, -1)"}},"name":"valueGeometryPickerGeometryArray","position":"120,760","title":"Fix Picker \"Geometry\" Array","transitions":[{"id":27,"inputs":{},"position":"240,950 240,980","sourceConnector":"bottom","target":{"id":13},"targetConnector":"top"}]},{"action":"gcx:wf:core::SetProperty","description":"The original **`state`** array is replaced with the above spliced array, removing the bad point that was just drawn.","id":17,"inputs":{"object":{"accessors":["$valueGeometryPickerObject"],"annotations":[{"count":26,"index":0,"kind":"idref"}],"code":"$valueGeometryPickerObject.result","source":"$valueGeometryPickerObject.result"},"propertyName":"state","propertyValue":{"accessors":["$valueGeometryPickerStateFix"],"annotations":[{"count":28,"index":0,"kind":"idref"}],"code":"$valueGeometryPickerStateFix.result","source":"$valueGeometryPickerStateFix.result"}},"position":"120,610","title":"Set Property","transitions":[{"id":29,"inputs":{},"position":"240,730 240,760","sourceConnector":"bottom","target":{"id":15},"targetConnector":"top"}]},{"action":"gcx:wf:core::CreateValue","description":"Gets all the items in the **`state`** properties of the Geometry Picker [object] except the last one (assumed unwanted from the above **`if`** logic).","id":19,"inputs":{"expression":{"accessors":["$valueGeometryPickerObject"],"annotations":[{"count":26,"index":0,"kind":"idref"}],"code":"$valueGeometryPickerObject.result.state.splice(0, 1)","source":"$valueGeometryPickerObject.result.state.splice(0, 1)"}},"name":"valueGeometryPickerStateFix","position":"120,410","title":"Fix Picker \"State\" Array","transitions":[{"id":31,"inputs":{},"position":"240,580 240,610","sourceConnector":"bottom","target":{"id":17},"targetConnector":"top"}]},{"action":"gcx:wf:core::CreateValue","id":21,"inputs":{"expression":{"accessors":["$form1"],"annotations":[{"count":6,"index":0,"kind":"idref"}],"code":"$form1.state.geometryPicker1","source":"$form1.state.geometryPicker1"}},"name":"valueGeometryPickerObject","position":"120,310","title":"Geometry Picker Object","transitions":[{"id":33,"inputs":{},"position":"240,380 240,410","sourceConnector":"bottom","target":{"id":19},"targetConnector":"top"}]},{"action":"gcx:wf:ui::Alert","id":23,"inputs":{"text":"Bad Geometry Pick"},"position":"120,250","title":"Bad Geometry Pick","transitions":[{"id":35,"inputs":{},"position":"240,280 240,310","sourceConnector":"bottom","target":{"id":21},"targetConnector":"top"}]},{"action":"gcx:wf:core::If","description":"The logic that should determine if you want to delete the last drawn point or keep it.","id":25,"inputs":{"condition":"0=1"},"position":"-30,90","title":"If Statement","transitions":[{"branch":"false","id":37,"inputs":{},"position":"210,155 240,155 240,250","sourceConnector":"right","target":{"id":23},"targetConnector":"top"},{"branch":"true","id":44,"position":"-30,155 -60,155 -60,250","sourceConnector":"left","target":{"id":43},"targetConnector":"top"}]},{"action":"gcx:wf:ui::Alert","id":43,"inputs":{"text":"Good Geometry Pick"},"position":"-180,250","title":"Good Geometry Pick"},{"action":"gcx:wf:core::Annotation","description":"The drawn point meets your logic and stays in the geometry picker.","id":45,"inputs":{},"position":"-180,310","title":"Success"},{"action":"gcx:wf:core::Annotation","description":"The drawn point doesn't meet your logic and is deleted from the Geometry Picker form element.","id":48,"inputs":{},"position":"120,1130","title":"Fail"},{"action":"gcx:wf:core::Annotation","description":"This appears to effect the actual map object which could be problematic if only deleting the geometry below.","id":49,"inputs":{},"position":"360,410","title":"Notes"},{"action":"gcx:wf:core::Annotation","description":"It appears functions (e.g., the **`splice`** function) don't edit the original VertiGIS objects. So we update instead.","id":50,"inputs":{},"position":"360,610","title":"Notes"},{"action":"gcx:wf:core::Annotation","description":"Same logic as the above **Set Property**.","id":53,"inputs":{},"position":"360,980","title":"Notes"},{"action":"gcx:wf:core::Annotation","description":"This is the backend geometry used for the objects. Deleting this will get rid of the geometry used in calculations and update the drawn rows in the form element appropriately.","id":56,"inputs":{},"position":"360,760","title":"Notes"}],"title":"change-geometryPicker1"}],"deploymentConfig":{"supportedApps":{"EXB":true,"GWV":true,"WAB":true}},"designerVersion":"5.27.1+8","forms":[{"defaults":{},"elements":{"footer":{"enabled":true,"items":{"0":{"default":true,"index":0,"label":{"markdown":"Submit"},"validates":true,"value":"submit"},"1":{"index":1,"label":{"markdown":"Cancel"},"validates":false,"value":"cancel"}},"section":"footer","type":"ButtonBar"},"geometryPicker1":{"autoActivate":true,"enabled":true,"format":"point","index":0,"itemLabel":{"markdown":"Location"},"prompt":{"markdown":"Add Location"},"require":true,"rowIndex":0,"rowNumber":0,"size":10,"title":{"markdown":"Geometry Picker"},"type":"GeometryPicker"},"header":{"section":"header","title":{"markdown":"Form Title"},"type":"Header"}},"id":5}],"start":{"id":3},"transitions":[{"branch":"changed$geometryPicker1","id":10,"source":{"id":4},"target":{"id":9}}]}

     

    Here's what it looks like in VertiGIS:


    Either way, hope you got a good solution and/or that this helps others!

    2

Du måste logga in om du vill lämna en kommentar.