POST
|
got it. thanks! btw, what is the main difference between looping with some vs forEach?
... View more
10-10-2018
08:13 AM
|
0
|
1
|
1100
|
POST
|
Got it working with view.graphics.some not view.graphics.graphics The main original issue was cannot read property Name of null and this happened because I had created some graphic objects before the user did any clicking and those objects did not contain the custom attribute of Name but my new objects did have the Name attribute. once I added the Name attribute to all the objects the code below works fine view.graphics.some(function (graphic) { if (graphic.attributes["Name"] == "selected-" + lastObjectID) { view.graphics.remove(graphic); return true; } });
... View more
10-10-2018
08:09 AM
|
0
|
1
|
1100
|
POST
|
thanks for your help. I'm still having problems. when I do view.graphics.graphics.some I get "cannot read property 'some' of undefined" so it never does the loop when I do view.graphics.some it goes into the loop but then I get "cannot read property Name of null" fyi, I create the graphics fine doing view.graphics.add(polygonGraphic) not view.graphics.graphics.add
... View more
10-10-2018
07:45 AM
|
0
|
3
|
1100
|
POST
|
Each time a user clicks on a list I add a new graphic on top of the clicked item. However, I want to remove the last graphic that was created. fyi, I can't do view.graphics.clear because before the user click I've created graphics that I need to keep. This creates the graphic without problems. function onListClickHandler(event) { const target = event.target; const resultId = target.getAt tribute("data-result-id"); // get the graphic corresponding to the clicked parcel const result = resultId && graphics && graphics[parseInt(resultId, 10)]; var selectFillSymbol = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [111, 0, 255, 0.3], outline: { // autocasts as new SimpleLineSymbol() color: [0,0,0], width: 2 } }; var polygonGraphic = new Graphic({ geometry: result.geometry, symbol: selectFillSymbol, attributes: simpleFillAttributes }); view.graphics.add(polygonGraphic); But none of these ideas below remove the graphic capturing the reference of the last object var lastResult = result view.graphics.remove(lastResult); view.graphics.remove(graphics[parseInt(lastResultId,10)]; I tried adding an attribute to the new object since result.attributes.OBJECTID works and gives back the objectid of the original clicked item. var simpleFillAttributes = { Name: "newgraphic-" + result.attributes.OBJECTID }; var polygonGraphic = new Graphic({ geometry: result.geometry, symbol: selectFillSymbol, attributes: simpleFillAttributes }); and then looping through all the graphics but this give me "cannot read property Name of null" view.graphics.forEach(function (graphic) { if (graphic.attributes["Name"] == "newgraphic-" + result.attributes.OBJECTID) { graphic.remove(graphic); } }); How can I remove the last graphic created?
... View more
10-09-2018
05:06 PM
|
0
|
7
|
1271
|
POST
|
here is how to do it in 10.5.1 https://community.esri.com/message/802272
... View more
09-26-2018
12:46 PM
|
0
|
0
|
400
|
POST
|
thanks Robert. I've been exploring that concept but I don't understand how to make a graphic that matches the shape of results.features[0].attributes.OBJECTID so that it only highlights that particular objectid on the featurelayer. could you point me to an example of that?
... View more
09-26-2018
12:09 PM
|
0
|
2
|
607
|
POST
|
I'm a n00b and I understand that the following only works with 10.6.1 enterprise server layerView.highlight(results.features[0].attributes.OBJECTID) however, I have 10.5.1 server and would like to know how to achieve the same thing? Apparently I can use SceneView But how do I convert my map.add(featureLayer) to a sceneview so highlihght works?
... View more
09-26-2018
11:45 AM
|
0
|
4
|
722
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|