Select to view content in your preferred language

Search task that returns intersecting layers?

4423
19
04-14-2016 08:02 AM
LeoLadefian4
Deactivated User

I'm looking for a search feature that allows you to search for an address (point, polygon) and the return results would return any intersecting layers.  Anything like that out there?

Tags (1)
0 Kudos
19 Replies
RobertScheitlin__GISP
MVP Emeritus

Leo,

  There is no widget out there that I am aware of that does that. But it would be pretty simple to bind the otb Search widget result to launch the Identify widget.

LeoLadefian4
Deactivated User

Can the onboard Search widget be modified to execute a popup based on the search result as well?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Leo,

  Sure just edit the Widget.js _onSelectResult function (lines 29 to 34):

_onSelectResult: function(e) {
        var result = e.result;
        console.info(result);
        if (!(result && result.name)) {
          return;
        }
        var dataSourceIndex = e.sourceIndex;
        var sourceResults = this.searchResults[dataSourceIndex];
        var dataIndex = 0;
        for (var i = 0, len = sourceResults.length; i < len; i++) {
          if (jimuUtils.isEqual(sourceResults, result)) {
            dataIndex = i;
            break;
          }
        }
        query('li', this.searchResultsNode)
          .forEach(lang.hitch(this, function(li) {
            html.removeClass(li, 'result-item-selected');
            var title = html.getAttr(li, 'title');
            var dIdx = html.getAttr(li, 'data-index');
            var dsIndex = html.getAttr(li, 'data-source-index');

            if (title === result.name &&
              dIdx === dataIndex.toString() &&
              dsIndex === dataSourceIndex.toString()) {
              html.addClass(li, 'result-item-selected');
            }
          }));
        // Once we have the "mapPoint" object we convert it to a "screenPoint" object
        setTimeout(lang.hitch(this, function(){
          var mpPt = result.feature.geometry;
          var scrPt = this.map.toScreen(mpPt);
          this.map.emit("click", { bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });
        }), 500);
      },
LeoLadefian4
Deactivated User

Cool, that's pretty slick. I do have some feature layers in the search box as well, whenever i use those to search it seems to cancel out the popup.  Anyway to isolate those searches?

0 Kudos
LeoLadefian4
Deactivated User

I assume the "show pop up for found feature" is interfering?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Leo,

  Correct, I turned off "show pop up for found feature" when testing this.

0 Kudos
LeoLadefian4
Deactivated User

did you happen to try it with a feature or dynamic layer in the search box?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Leo,

  I did not.

0 Kudos
LeoLadefian4
Deactivated User

do you happen to have a quick example of that?

thanks!

0 Kudos