Pass Search Parameter in URL

7904
26
11-19-2014 12:21 PM
mpboyle
Occasional Contributor III

I have downloaded and placed an app built with the web app builder beta 3 on our web server.  The app works fine, but I have been asked if it's possible to pass a search parameter in the URL...something like http://gis.linncounty.org.../?gpn=1234567890  ...  where the app would zoom to the parcel with an id of 1234567890.

I don't know much of anything about JavaScript so I was wondering if this is possible, and if so, what it would take to implement?

Thanks!

26 Replies
RobertScheitlin__GISP
MVP Emeritus

David

  Can you share the url you get from the export url?

0 Kudos
DavidBuehler
Occasional Contributor III
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

David,

   OK I see now that you missed the part in the help doc that says the eSearch widget has to opened for the url search to work. So you just need to set the widget to be opened at startup.

DavidBuehler
Occasional Contributor III

Thanks.  I did indeed miss that.  It works.  thanks for you help.

0 Kudos
MiriEshel
New Contributor III

Hi Robert,

I looked at your live demo: ArcGIS Web Application. It looks pretty nice ans impressive. I also saw the URL Search capabilty.

I wanted to ask if it can make the URL search on two fields. When I looked at Louisville Zoning layer, I saw there are 2 parameters for the search: Zoning type & Zoning name. I asked for Zoning type = RESIDENTIAL and Zoning name = RES MULTI-FAMILY (see attached file) but when I Exported the Search URL, I saw only reference to Zoning name : http://gis.calhouncounty.org/WAB/V1.1.1/widgets/eSearch/index.html?esearch=RES MULTI-FAMILY&slayer=0&exprnum=0

Is it possible to search by 2 fields in the URL?

Thanks,

Miri

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Miri,

   Sure the URL Search parameters are exactly the same of the old Flex Version. Live sample of this in action can be found here:

ArcGIS Web Application

MiriEshel
New Contributor III

Hi Robert,

Thank you for your answer but I think I was not understood...

I want to ask about two fields: field1 = 'something' AND field2 = 'something else' (without definition expression) and be able to use it in URL.


I see in the code that it takes only the last value:

for(var s=0; s<content.length; s++){

          eVal = content.value.toString();

        }


It does not concatenate the conditions, eVal takes only the last one.

As for now, I guess your widget does not support it.

Thanks again,

Miri

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Miri,

   That is correct. Currently only one search expressionNum, search layer id and, actual search term is supported.

JeffBigos
Esri Contributor

Hi Matthew,

In addition to the widget listed above take a look through the following Javascript sample:

History API to track selected feature | ArcGIS API for JavaScript

This sample touches on the classes in the api that would help support the functionality you are looking for.

One of the main goals is to see how you can utilize the history api, but it runs off of a query string in the url which is what you are looking for.

To provide that functionality the api supports the following class:

https://developers.arcgis.com/javascript/jsapi/esri.urlutils-amd.html

this class supports a url to object function that is used in the sample here:

//extract the parcel id from the url
       
function getParcelFromUrl(url) {
         
var urlObject = urlUtils.urlToObject(url);
         
if (urlObject.query && urlObject.query.parcelid) {
           
return urlObject.query.parcelid;
         
} else {
           
return null;
         
}
       
}

The orange line I highlighted above is the where the parcel ID is obtained in the application.

Later in the application that obtained ID is used to select the required features:

function selectParcel(parcelid) {
         
if (parcelid) {
           
var query = new Query();

when that sample runs you pass in a url to the application with the id of the parcel you want to zoom to:

http://developers.arcgis.com/javascript/samples/exp_history/?parcelid=1920352007

Hope this helps as to the background of that can be obtained and used.

Jeff

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

All,

   My Enhanced Search widget with URL search and MORE is now available (live preview site also available). The widget feature help documentation (just like all the esri widget do). Check it out here: Enhanced Search Widget Beta 3.2

0 Kudos