Select to view content in your preferred language

Passing Parameter to Flex Viewer

20491
114
01-14-2011 03:46 AM
CurtNielsen
Occasional Contributor
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
MollyAzami
Emerging Contributor
aha!, so I was not going crazy!
Thanks Robert.
so, I need to co throught the code and change where it says SiteContainer to ViewerContainer and put the init() code into the ViewerContainer instead of the SiteContainer?

that is what I will try...
0 Kudos
MollyAzami
Emerging Contributor
So that solution isn't for 2.x.  I have run into many other errors, such as creating an AppEvent.  You are passing 4 parameters, but the 2.x constructor is looking for <=3.

I don't know what other error I am going to run into...and not sure how to fix this one mentioned...not sure which params we need to pass.  seems very different from older version of the viewer.
0 Kudos
MollyAzami
Emerging Contributor
Well, I just went with the string and then null, null, to get passed the error.

Now the errors with BaseWidget and IBaseWidget
in the TimerComplete function:
This section:


 if (bWidget){
 var bWidg:BaseWidget = bWidget.getInstance();
 var vSW:SearchWidget = bWidg as SearchWidget;
 vSW.queryParam(xParam);
 } else {
 var bWidget2:IBaseWidget;
 bWidget2 = SiteContainer.getInstance().widgetManager.getWidget(id) as IBaseWidget;
 var vSW2:SearchWidget = bWidget2 as SearchWidget;
 vSW2.queryParam(xParam);
 }


Is there something here that has changed in 2.2?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Molly,


   In my enhanced Search Widget there is a PDF called Enhanced Search Widget URL Search Configuration.pdf that has all the code changes that are updated for Flex Viewer 2.x try looking there.

http://www.arcgis.com/home/item.html?id=5d4995ccdb99429185dfd8d8fb2a513e
0 Kudos
glennhazelton
Deactivated User
question:
can the ?EXT take just a single set of coords? i am interested in having it zoom to a pt instead of a poly.


Jon,

   Sure here is the code to change in the MapManager.mxml

            //map load complete
            private function mapLoadComplete(event:MapEvent):void
            {
//My Add
    map.zoomSliderVisible = false;
    map.logoVisible = false;
    
    try
    {
     if (ExternalInterface.available)
     {
      var timer:Timer;
      var result:URLVariables = new URLVariables();
      var urlSubstring:String = ExternalInterface.call("window.location.search.substring", 1);    
      if (urlSubstring && urlSubstring.length > 0 && urlSubstring != "debug=true")
      {
       result.decode(urlSubstring);
       // Parse URL
       var xExt:String;
       var xUrlParam:String;
       if (result["EXT"])
        xExt = result.EXT;
       
       if (!xExt == ""){
        var extArray:Array = xExt.split(",");
        var extent:Extent = new Extent(Number(extArray[0]), Number(extArray[1]), Number(extArray[2]), Number(extArray[3]),map.spatialReference);
        map.extent = extent;
       }
      }
     }
    }
    catch (error:Error){}
//End My Add
            }


to use it just append something like:  ?EXT=644988.5757,1173575.0875,645690.0041,1173863.1558 to the url.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Glenn,

   Nope... You would have to modify it to use a MapPoint instead of an extent.
0 Kudos
JonFisher
Emerging Contributor
question:
can the ?EXT take just a single set of coords? i am interested in having it zoom to a pt instead of a poly.


The way that I dealt with this was to use field calculator to generate an extent based on a point location. Basically you just pick the scale you want, figure out how many meters that corresponds to, and then add or subtract half of that value from the point location to the 4 extents.
0 Kudos
NathanEnge
Esri Contributor
Steve,

I've successfully modified the code to pass a parcel ID in the URL. The map opens and zooms to the parcel which has been overlaid by a graphic. I'm attaching a text file with explanations and code.

Marc


Marc,
are there any changes to this code for it to be 2.3.x compatible?
0 Kudos
glennhazelton
Deactivated User
mark, i dont see the attached txt file.
love to have give it a try.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Glen,

   I made this ability pretty easy (well documented), and very configurable in the eSearch widget. Have you looked at it?
0 Kudos