Flex select and zoom to a feature by values from datagrid

4442
18
Jump to solution
11-19-2014 12:20 AM
LiYao
by
New Contributor III

Dear all,

In my flex application, I have a function to retrieve feature attributes in a datagrid.


In the datagrid, I add a context menu "Select and Zoom", when click this context menu on a selected row, I need to select and zoom to the feature based on the "Item No" and "Item Sub No" value.

99999999999999999.jpg

The feature layer is a polyline layer.


I tried to find a solution from ESRI smaple, but no luck.  Could anybody please give me help on this? Thanks a lot.

I am using Adobe Flash Builder 4.6 and arcgis api for flex 3.6.

0 Kudos
18 Replies
LiYao
by
New Contributor III

Hi Robert,

You are so nice, thanks a lot. This time no fault error.

But still 2 issues:

(1) If I use the updated GetLoc() no result displayed in the datagrid.       

          public function GetLoc(event:ResultEvent):void {

                    // Databind data from webservice to datagrid                

                    datagrid.dataProvider = new ArrayCollection(event.result as Array);

          }

(2) If I use the old GetLoc function, result will display, but when I try to use "select and zoom", still the same, only the busy cursor there.

This time I use another layer and query on the Segment_ID only, the following is what can found in the querytask url.

5555555555555555555555.jpg

and query.where = "Segment_ID ='1988/03-1'";    //this time use exact value to test

And what I see in manually select this feature:

8888888888888888.jpg

But still not work. So sorry to trouble so much, but this one drive me crazy.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Li Yao,

  So have you inspected the query.where string to see if it is what you are expecting by placing a breakpoint in your code or a trace like this:

                        query.where = "Item_No = '" + datagrid.selectedItem.itemNo + "' and Sub_No = '" + datagrid.selectedItem.subNo + "'";
                        trace(query.where);
0 Kudos
LiYao
by
New Contributor III

Hi Robert,

Yes I trace the query statement and also verified it in arcmap.

Thanks.

0 Kudos
LiYao
by
New Contributor III

Hi Robert,

Currently situation is I can confirm the query feature exists.

BUT the strange thing is in both cases(the feature exists or not exist), it always show the busy cursor.

What may be the possible reason for this problem?

Thanks for the help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Li Yao,

  The portions of your code where you are using this.cursorManager.removeBusyCursor(); are not portions that you actually use. So the the busy cursor will stay unless you put that line in some code that is actually being called.

Maybe try this code update (line 8):

                                var unionExtent:Extent; 
                                var myFirstGraphic:Graphic = featureSet.features[0]; 
                                unionExtent = Polyline(myFirstGraphic.geometry).extent; 
                               
                                for each (var myGraphic1:Graphic in featureSet.features) 
                                { 
                                    graphicsLayer.add(myGraphic1);
                                    if(myGraphic1.geometry !== myFirstGraphic.geometry){
                                        unionExtent = unionExtent.union(Polyline(myGraphic1.geometry).extent);
                                    }
                                } 
                                map.extent = unionExtent;
0 Kudos
LiYao
by
New Contributor III


Thank you Robert for the help on this topic.

But the problem still there. I trace the progress and find the application stuck at this line:

unionExtent = Polyline(myFirstGraphic.geometry).extent;

And I found the code will NOT satisfy the condition of :(myGraphic1.geometry !== myFirstGraphic.geometry).

Thanks!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Li Yao,

   So are you sure that myFirstGraphic.geometry is not null? Are you sure that the geometry is actually a Polyline?

0 Kudos
LiYao
by
New Contributor III

Hi Robert,

Yes myFirstGraphic.geometry is not null and the geometry is polyline.

The code seems partially work now, it can zoom to the feature but not select the feature.

Is there anything missing?

Thanks a lot!!

0 Kudos
LiYao
by
New Contributor III

Hi Robert,

I have 2 layers (1 polyline, 1 polygon). I use the same code (except to change polyline to polygon), it works properly (zoom to the feature, also select the feature).

Since this thread is too long, I create a new thread to make it clear. thanks.

0 Kudos