Parse URL Parameters in Tax Parcel Viewer

2126
3
Jump to solution
06-23-2014 04:29 PM
RyanKammerer1
New Contributor III
I've configured the Tax Parcel Viewer (10.2) for our City's needs, and now I would like to be able to parse the URL parameter of an attribute when selected. In other words, when a parcel is selected, I would like the parcel ID to be parsed as a parameter in the URL. Similar to this html5 sample viewer: https://developers.arcgis.com/javascript/jssamples/exp_history.html.

The problem is that I can't figure out how the incorporate this feature into the tax parcel viewer application. I believe it needs to be in the locator.js file,  and could be accomplished with-

"if (selection.length > 0) {
              var getParcel = selection[0].attributes["APN"];
              //Refresh the URL with the currently selected parcel
              if (typeof history.pushState !== "undefined") {
                window.history.pushState(null, null, "?getParcel=" + selection[0].attributes.APN);
              }
            }"

-but I have had any luck getting this to work. I'm wondering if anyone has attempted the same  and maybe had success.

Any help would be much appreciated!

Thank you
0 Kudos
1 Solution

Accepted Solutions
RyanKammerer1
New Contributor III
Yeah! I figured it out. In case anyone else is interested, it's actually very, very simple.

First, in the default.htm file, you need to reference the ArcGIS JavaScript 3.9 API using:

<link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css">

Then, in the locator.js file, at the function to populate parcel information (about line 606), add this to selectedParcel

selectedParcel = feature.attributes[parcelAttributeID];
  //Refresh the URL with the currently selected parcel
              if (typeof history.pushState !== "undefined") {
                window.history.pushState(null, null, "?getParcel=" + selectedParcel);
              }

after that, if everything else is configured, your selected parcel ID should show up as a parameter to the URL.

Wow, it's always much simpler than I think.

Hope this saves someone some time!

View solution in original post

0 Kudos
3 Replies
OwenEarley
Occasional Contributor III
Check out this example: http://jsbin.com/hobomode/2

I just added your JavaScript to the selectParcel() function in the ESRI sample:

function selectParcel(parcelid) {
 if (parcelid) {
  var query = new Query();
  query.where = "PARCELID = '" + parcelid + "'";
  var deferred = parcels.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (selection) {
   var center = graphicsUtils.graphicsExtent(selection).getCenter();

   // add parcel to browser history
   var apn = selection[0].attributes.APN;
   if ((typeof history.pushState !== "undefined") && (apn)) {
    window.history.pushState(null, null, "?getParcel=" + apn);
   }

   var extHandler = map.on("extent-change", function () {
    extHandler.remove();
    //zoom to the center then display the popup 
    map.infoWindow.setFeatures(selection);
    map.infoWindow.show(center);
   });
   map.centerAt(center);
  });
 }
}
0 Kudos
RyanKammerer1
New Contributor III
Hi Owen,

Thanks for your response, I appreciate the help, but I think the example you gave is from the html5 esri example. I'm trying to take the functionality of that sample and incorporate into the JSAPI Tax Parcel Viewer. (http://tryitlive.arcgis.com/TaxParcelViewer/)

I'm hoping someone out there has had better luck with this than I'm having.

Thanks

Ryan
0 Kudos
RyanKammerer1
New Contributor III
Yeah! I figured it out. In case anyone else is interested, it's actually very, very simple.

First, in the default.htm file, you need to reference the ArcGIS JavaScript 3.9 API using:

<link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css">

Then, in the locator.js file, at the function to populate parcel information (about line 606), add this to selectedParcel

selectedParcel = feature.attributes[parcelAttributeID];
  //Refresh the URL with the currently selected parcel
              if (typeof history.pushState !== "undefined") {
                window.history.pushState(null, null, "?getParcel=" + selectedParcel);
              }

after that, if everything else is configured, your selected parcel ID should show up as a parameter to the URL.

Wow, it's always much simpler than I think.

Hope this saves someone some time!
0 Kudos