Passing Parameter to Flex Viewer

16879
114
01-14-2011 03:46 AM
CurtNielsen
New Contributor III
I would like to pass a parameter, parcel id, to flex viewer and have the map pan to that location. I have modified the Search widget to use a layer that we can search by parcel ID. Just want the same capability if I pass a parameter, paracle ID, to http://mynode/FlexViewer. Maybe something like http://mynode/FlexViewer?request=widget&version=2.1&WidgetName=Search&ParcelID=1234

Thank you!
Tags (2)
0 Kudos
114 Replies
ScottSnider
New Contributor III
Any help with this anyone?

Another rookie question about this topic!

I've made the changes to MapManager as mentioned and I can successfully search with what appears to be the bounding coordinates as given with an example with the code change.  I don't know if I missed this somewhere, but what changes would I need to make to be able to search on an X,Y instead of bounding coords?

The application is for a utility billing software we use, we push centroids of the parcel with x,y to the database for the utility billing.  We have then added a button that will pass a query string to pull up a web map of the location.  Alternatively we could use the other examples of passing a parcel ID, but if there are parcel changes (we do not maintain the parcels) then we would not get a result.  By passing x,y we are guaranteeing that the map will at least zoom to where the parcel used to be.

Thanks,
Scott
0 Kudos
MarkYerington
Occasional Contributor III
I knew that it was something with how long it takes the Flexviewer 2.3 to load all the elements on the screen, and when it is trying to run the query the search widget had not been loaded by this time.  I changed the line:
timer = new Timer(8000, 1);
to
timer = new Timer(12000, 1);
in the mapLoadComplete function and now the query is ran every time.  Now it does not run the utimerComplete function until the search widget is actually visible on the screen.  Thanks for everyones help on this issue.
Mark Yerington
0 Kudos
JustinCarasick
New Contributor III
sorry to jump in but have a slight issue. all the above works great. able to use the querytask in the maploadcomplete event and everything works great. THANK YOU.

But I have a little bug I think. On top of querying a feature and zooming to the feature (which works), I want to turn off my imagery layer and turn on all my others.

         
var layers:ArrayCollection = map.layers as ArrayCollection;
for each (var layer:Layer in layers)
{
          
    if    (layer.name.toLowerCase() == "imagery")
    {
             layer.visible = false;
    }
    else
    {
 layer.visible = true;
    }
}


the problem is that some layers draw and scale correctly but some layers seem to freeze at a particular scale and not refresh.

so if I use this code when I zoom in some layers don't refresh and stay at the previous zoom scale and cause obvious alignment/display issues. once this happens, if I use the TOC widget and turn the layer on and off again everything works correctly again.


any ideas?

i attached some screen graps. the 1st image shows when you first zoom in using the querytask code in this thread. the second image is when I zoom out after that. you will see some of the layers won't refresh and the scale gets out of wack. if i toggle the layer(s) not drawing correctly (or not refreshing) they will draw properly again.

thanks,
Justin
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

   I think it is going to have something to do with your zoom code and timing issues. Post the code that you are using in the MapLoadComplete.
0 Kudos
JustinCarasick
New Contributor III
Justin,

   I think it is going to have something to do with your zoom code and timing issues. Post the code that you are using in the MapLoadComplete.


Think your right. I read a couple of other posts in more detail and moved the code (the exact same code) into the layerloadComplete event and it now works. Here is the code snippet.

    if (ExternalInterface.available)
    {
     var result:URLVariables = new URLVariables();
     var urlSubstring:String = ExternalInterface.call("window.location.search.substring", 1);
     
     if (urlSubstring && urlSubstring.length > 0 != "debug=true")
     {
      result.decode(urlSubstring);
     
      // Parse URL
      var qValue:String
      if  (result["excavationpermit"])
      {
       qValue = result["excavationpermit"]; 
       
       var queryTask:QueryTask = new QueryTask();
       var query:Query = new Query();
       query.returnGeometry = true;
       query.where = "order_no = '" + qValue + "'";
       queryTask.url = "http://df21pce00255325/ArcGIS/rest/services/Common_Utilities/FeatureServer/0";
       queryTask.execute(query, new AsyncResponder(onResult, onFault));
       
       function onResult(featureSet:FeatureSet, token:Object = null):void 
       {
        if (featureSet.features.length == 0) 
        {
         Alert.show("Excavation Permit Not Found. Please Try Again.");
        }
        else 
        {
         //uninon the sel graphic extents and zoom
         var unionExtent:Extent;
         var myFirstGraphic:Graphic = featureSet.features[0];
         unionExtent = Polygon(myFirstGraphic.geometry).extent;
         for each (var myGraphic1:Graphic in featureSet.features)
         {
          
          unionExtent = unionExtent.union(Polygon(myGraphic1.geometry).extent);
         }
         map.extent = unionExtent; // Zoom to queried polygon
         map.scale = 250;
         
         // make sure the whole extent is visible
         if (!map.extent.contains(unionExtent))
         {
          map.level--;
         }
         
         //turn on required layers
         var layers:ArrayCollection = map.layers as ArrayCollection;
         for each (var layer:Layer in layers)
         {
          if (layer.name.toLowerCase() == "imagery")
          {
           layer.visible = false;
          }
          else
          {
           layer.visible = true;
          }
         }
         
         
        }
       }
       function onFault(info:Object, token:Object = null):void {
        Alert.show("Excavation Permit Not Found. Please Try Again.");
       }
        }
        }
    }    
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

   Glad to hear you have it working.
0 Kudos
JustinCarasick
New Contributor III
Justin,

   Glad to hear you have it working.


Yes, appreciate you responding.
0 Kudos
JeffHarmon
New Contributor
So, once you get the paramters passed and your feature selected is there an easy way to turn off the overlay?
0 Kudos
CarolineCochrane
New Contributor III
Hi Marc,

I wondered if you figured out how to avoid the query method defaulting to use the LIKE syntax?
I have incorporated the code to allow the parameters to be passed ok, but instead of using the line:

...
query.text = vValue;
...

i would like to search on a EQUALS expression so that when the last part of the URL is entered it searches this value exactly.

If possible can you provide any help please?

I imagine it something like query.where = expr
But im not sure on how to go about this.

All the best,


Caroline
0 Kudos
MarcWeinshenker1
Occasional Contributor
Hi Caroline,

Sorry, but changing the query parameters wasn't something I ever pursued, and I don't have a solution other than pursuing the suggestion I made originally.

Marc
0 Kudos