Inprovements to "Select By Attributes 2.8" widget

1187
12
10-23-2018 05:23 AM
RichBell
Occasional Contributor

The original widget developed by Adrián Pérez Beneito works perfect for Feature Layers only!

Is anyone willing to improve this widget to work with Group Layers, have it zoom to selected and add the results to the attribute table. This improvement would greatly benefit a lot of SQL users in querying large complicated data sets.

Any help would be appreciated.

Thank You!

0 Kudos
12 Replies
by Anonymous User
Not applicable

EDIT:

--- deleted code as it didn't provide a working solution >>>  see below for zip file

Hi Rich,

A little late on a response here, but for you and anyone else who might happen by -- if you want a Zoom to Selected button, copy the below code in. The work Adrián did on this widget was great.

< CODE DELETED>

0 Kudos
RichBell
Occasional Contributor

Thank You for looking into this!

Well I tried to include your enhancement but with no luck.

I get Bootstrap errors and it will not zoom to the selected element.

Could you possibly attach your updated version?

This could provide a better outcome for me.

Again thank you.

Rich

0 Kudos
by Anonymous User
Not applicable

Argh! Sorry about that, Rich. I have done a lot more work than just adding the Zoom to Selected button.

(I've actually removed all the bootstrap dependencies in my version as I found they had conflicting classNames with the Attribute Table).

Here is a list of changes I've made:

* Zoom to selected button (will reproject selection to match the map's spatial ref if required)
* Responds to layers added via Add Data widget
* A stubbed out tab to create pre-defined queries for well established workflows
* Buttons enable/disable depending on the current stat of a workflow
* Ability to query MapServices
* Removal of bootstrap styling
* Removal of _some_ JQuery. (Not all JQuery references have been removed)

I've attached the entire widget. I hope it works for you.

0 Kudos
RichBell
Occasional Contributor

Wow!

Looking good,

1.) Is there a config file to follow? How to limit the feature list to query

2.) I'm receiving this error for Feature Services only:

TypeError: Cannot read property 'spatialReference' of undefined
    at Object._zoom (Widget.js?wab_dv=2.9:515)
    at Object.ZoomSelect (Widget.js?wab_dv=2.9:501)
    at HTMLDivElement.<anonymous> (init.js:63)

3.) Anyway to add the results to the attribute table?

I know I ask too much, but Love it so far !!!!!

0 Kudos
by Anonymous User
Not applicable

Hi Rich,

No, no config file to limit to particular services. That's beyond the scope of my project. My project requires all layers in the map to be queryable.

Can you share the URL of the feature service you're using? I dont understand why the code isn't seeing the spatialReference of your featureservice. I understand the error, just not why you're getting it.

Not sure what you mean about the results to the attribute table? When I perform a query and open the attribute table, I see the selected record(s) highlighted in the table.

thanks

0 Kudos
RichBell
Occasional Contributor

This is the URL it will not zoom too.

https://gisapp.mahoningcountyoh.gov/arcgis/rest/services/PUBLIC_WEBSITE_SANITARY_EDIT/FeatureServer/0

I have been trying to remove the full title of the services and just display the Service Name only, again no luck

Maybe you could help in doing this?

This widget has a lot of potential as it did in the old Flex version, just needs a few tweaks….

Thanks Again!

0 Kudos
by Anonymous User
Not applicable

Rich,

As a "quick fix" if you find the _performQuery function, you can tell the function to returnGeomerty=true for all layers.

I'm not exactly sure why, but I'm only returning geometry for MapService layers, not FeatureLayers. I need to circle back to my test cases to understand why I'm doing this and if I really should be returning geometry for everything.

    query.returnGeometry = true;
/*     if (this.url.indexOf("MapServer") > 0) {
        query.returnGeometry = true;
    } */‍‍‍‍

And as I look more closely at your case, I see when selecting a single manhole point that I zoom way out when I'd need to actually zoom way in.

You may want to look at _zoom and update to a value that's more suitable.

      this.map.centerAndZoom(p, 10);

I'm looking for a better way than hardcoding the zoom level to set the zoom for individual points.

Edit:

Per: graphicsExtent and the single point 

I like this solution to zooming to a single point:

   var maxZoom = this.map.getMaxZoom();  
   this.map.centerAndZoom(p, maxZoom- 1);‍‍
0 Kudos
RichBell
Occasional Contributor

The zoom now works, I increased the zoom factor and it also works.

BUT I noticed that no highlight color is displayed for FEATURE Services the highlight color only works for MAP Services.

I’m not much of a programmer but I’m good at finding bugs……..

Thank You!

0 Kudos
by Anonymous User
Not applicable

Thanks, Rich, I do appreciate you being my 'tester'  .

I am seeing some odd behavior in the selection highlight not happening vs. table putting the selection on. I can't quite figure it out right now. I am doing the same thing the table is doing (but apparently not). A strange thing -- if you select the record in the table, then clear the table and perform the same SQL Query, the widget will put the selection on the map.

So yeah, I'm working on that and I've found another little thing with query syntax of numbers vs. strings, so I'm working on that too.

There's so many different workflows with this widget (map service, feature service, already in the map, added to the map, etc, etc)... your testing has highlighted I've missed a few of the cases. Thanks, again. I'll try to post an update version early next week.

0 Kudos