How to find a reference to each search result after I perform a search such that on clicking each reference/link, the map zooms in and an info template shows up for that result?

11-15-2015 09:55 PM
New Contributor

Though I have accomplished the task at hand, i wish to find a more efficient way to do this. If esri have provided a way to highlight the first search result on performing a search, why is there no way to highlight the second, third ..etc result? Why do i have to manually create an anchor tag to do this?

If there is a simpler way to perform this kindly let me know!

My Current method:

I am currently retrieving all the results after the search is complete in the following function and storing it in a global variable:


     //access and store in global variable  - allResults


For each of the data in allResults, I create a href link,  [<span class='link' onclick='searchTreeNum("+counter+");return false;'>] I zoom in and popUp the infoTemplate manually. This is done in the following function , where counter represents the index in the allResults that it must generate the popup for :

function searchTreeNum(counter){

            var feature = allResults[counter];



                var gs = new GeometryService(geometryLayerUrl);

                var bf = new BufferParameters();

                var p = new Point(feature.geometry.x,feature.geometry.y,feature.geometry.spatialReference);

                bf.geometries = [ feature.geometry ];

                bf.distances = [ 5 ];

                bf.unit = esri.tasks.GeometryService.UNIT_FEET;

                bf.spatialReference = feature.geometry.spatialReference;

                bf.outSpatialReference = map.spatialReference;

                gs.buffer(bf, function(bufResults) {

                  var g = new Graphic(bufResults[0], pointType2, feature.attributes, "");


                  var mp = webMercatorUtils.webMercatorToGeographic(p);







0 Kudos
2 Replies
Regular Contributor

Hello Meghna,

If my understanding is correct, you are storeing the search result  and creating a list of span and not displaying them on the map. and OnClick of the span you add/display them on the map with its popup window open. Also before adding you are converting the point into polygon with a buffer distance (I didn't understand why you are doing this).

Now about the "the second, third ..etc result", do you mean you wish to show all the seach result at once. It is possible you need to loop through results and add them to map. but, you will not be able to show the popup window for all the results. You may have to set up on click or mouse over event to show popup window for each of the results.


0 Kudos
New Contributor

Hi Thejus,

Firstly, thank you for answering my question. I am exactly doing as what you replied. What I wanted to know was how does the search zoom to the first result and open a popup automatically. The rest of the results are obtained as arrays which we need to process later and create popups on each click.

Is there any simpler way to do it than what i have done above?

If you need any further details about the code I will provide that to you.

Also, in the code above, I am creating a point based on the data in the result set and displaying it. Is there a more efficient way to do this?



0 Kudos