Search Address and get pop up window to show with underlying data

399
6
06-27-2019 09:27 AM
JohnWatermolen1
New Contributor III

If I create an application in web app builder where the user enters their address, is it possible that the information from the polygons that the point is located in automatically pops up instead of having to click a second time on the point?

0 Kudos
6 Replies
MarcDyke2
New Contributor II

I've done this using the JS api without WAB so it is definitely possible to do. I'm not sure about the WAB part though.

0 Kudos
JohnWatermolen1
New Contributor III

Would that be done in a web map? I am very new at all of this. Not sure how to do this.

0 Kudos
MarcDyke2
New Contributor II

I can't see why not, but I'm no expert. Essentially you want to run an identifyTask using the geometry that the search returns.  https://developers.arcgis.com/javascript/3/jsapi/identifytask-amd.html

There are of course a million ways to skin a cat and depending on the specifics of your situation you may need to do some messing about to get things to work correctly. The JS api samples are really helpful when working on this stuff. https://developers.arcgis.com/javascript/3/jssamples/

0 Kudos
KevinMacLeod4
Frequent Contributor

Hi John Watermolen‌ Yes I do this exact thing on my property app www.sagis.org/map  You could do a query above or as done below just tell the map to click in the centroid of the parcel and fire a click() event.

Go in to Widget.js in the Search widget folder. 

Find this section

//////// stating about here aroun line 970....  and paste code starting where indicated below..


if (dataSourceIndex !== 'all') {
dataSourceIndex = parseInt(dataSourceIndex, 10);
}
if (this.searchResults && this.searchResults[dataSourceIndex] &&
this.searchResults[dataSourceIndex][dataIndex]) {
result = this.searchResults[dataSourceIndex][dataIndex];
this.searchDijit.select(result);
}

////  PASTE NEW CODE IN STARTING HERE///

//////

setTimeout(lang.hitch(this, function () {
// added by me
var mpPt;
if (result.feature.geometry.type === "point") {
mpPt = result.feature.geometry;
} else {
mpPt = result.feature.geometry.getExtent().getCenter();
}
var scrPt = this.map.toScreen(mpPt);
this.map.emit("click", { bubbles: true, cancelable: true, mapPoint: mpPt, screenPoint: scrPt });
// end of added by me
}), 100);

//////  end of new code

},

0 Kudos
JohnWatermolen1
New Contributor III

Kevin,

I am assuming that you modified this in Web App Builder- Developer Edition? Just wanting to make sure

0 Kudos
KevinMacLeod4
Frequent Contributor

Yes

0 Kudos