Select to view content in your preferred language

Help with Enhanced Search Widget, Viewer, customization questions

4955
20
Jump to solution
09-19-2012 08:45 AM
MichelleKinseth
Emerging Contributor
Hello,
Last week I inherited a Flex Viewer that was built by someone else several (~6?) months ago, then put aside. When I was given the viewer I was also given a short list of customization's desired by the viewer owner, and so I'm trying to accommodate his requests. The viewer is built on Flex 2.5, and the Enhanced Search v2.x is the main functionality of the viewer. I have downloaded the recent upgrades for both but haven't been able to make the upgrade yet, mainly because the person who worked on this before me did some editing in some of the mxml files and so trying to track changes made in some of those files has been quite burdensome; honestly I'm not sure what in the new code are updates versus what were changes made by my predecessor; but that's something I'll have to figure out. The eSearch widget should be a bit simpler to upgrade, I hope.

My issues are thus:
1. The owner of the viewer does not want a popup to show when a search is completed in the eSearch widget. I've read some threads here that have mentioned commenting out things such as Highlight and/or MouseOver Events and I've tried several combinations of those various possibilities but nothing has worked. Any hints here would be very helpful and very much appreciated. (there are no popups enabled in the main config). Disabling the popup is a primary desire of the viewer owner so if nothing else, I'd really like to accomplish this for him.

2. The owner of the viewer does not want the search results to show in the widget "window", either. As the widget functions now, when a search is completed the results appear in the fixed table at the bottom of the map, in the search widget window, and in the popup (when activated). This is a redundancy of information for our particular use and the owner wants only for the results to appear in the fixed table. Is this possible? I feel comfortable making some changes to the compiled code if I am given some guidance because as it is I have no idea where to start. If this is not possible, that is fine too - I will happily tell the viewer owner that I can't do this for him.

3a. Is there any way to have the map open with a set of features selected (meaning symbolized as "highlighted" when the map initializes) as if the features had been selected from the search widget? The viewer displays water data, so features that aren't relevant to a user are shown along with the ones they are interested in and not until they perform a search with the widget can they tell which ones are applicable to their issue. Does that make sense? I have a feeling this one might not be possible, but I wanted to ask those who know more than I.

3b. Conversely, is there a way to disable selecting features that do not contain the url parameter (or part of it) that zoomed the map (the parameter is a unique ID to identify specific features as well as to define extent)?

4. I was asked to embed the Layer List and eSearch Widget into a sidebar of the viewer so they aren't "floating" above the map. I know there must be existing code for this functionality but I can't seem to find it in the help section.  

Please keep in mind that until last week I had never opened Flash Builder or seen the compiled code of a Flex viewer before (or any compiled code at all) though I've done a lot of xml editing. I am not a developer at all, but if given a path to follow I can usually suss out code through forums and help doc's. Sadly, ESRI has not helped me much with these particular tasks so now I'm asking for help! Three days of staring at this while randomly changing things without a real clue as to where to start is long enough, I think.

Thank you in advance for any help anyone can give me on any of these issues.
Tags (2)
0 Kudos
20 Replies
MichelleKinseth
Emerging Contributor
Michelle,

   So you are sure that you added the agslib-3.0-2012-06-06.swc to the libs folder?


haha, oops. No I don't have that one and I actually wondered about that. That particular swc wasn't in the Viewer for Flex download. Which is not convenient. The swc that came up when I followed the provided link to the ESRI site was the drslib-3.0-2012-9-6.swc. heh, now I feel silly...I'll find that now and add it.
0 Kudos
MichelleKinseth
Emerging Contributor
Michelle,

   So you are sure that you added the agslib-3.0-2012-06-06.swc to the libs folder?


Robert - thank you for your help thus far. I wondered if you had any idea as to why, even though I have the agslib swc added now, why I still have this one, single error in my index.mxml? I can't figure it out...

As it is, when I launch the app the web page opens white with "Error 2032" in text at the bottom; but if I comment out the line, the map opens with my data drawn but with the error as seen in the second image I posted. Thanks.

[ATTACH=CONFIG]17860[/ATTACH] [ATTACH=CONFIG]17861[/ATTACH]
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Michelle,

   What and why are you adding to the index.mxml?
0 Kudos
MichelleKinseth
Emerging Contributor
Michelle,

   What and why are you adding to the index.mxml?


The index.mxml was heavily edited/altered in the previous Flex version by my predecessor; I copied the code and pasted it into the 3.0 index.mxml.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Michelle,

   You should post that code as many package names have changed.
0 Kudos
MichelleKinseth
Emerging Contributor
Michelle,

   You should post that code as many package names have changed.


Thank you for your help Robert; this code all worked as expected in version 2.5 and now (in 3.0) the commented out line for ags.symbols shows as an error.

<!--
///////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010-2011 Esri. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////
-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:viewer="com.esri.viewer.*"
      xmlns:managers="com.esri.viewer.managers.*"
      xmlns:esri="http://www.esri.com/2008/ags"
      initialize="onAppPreinitialize(event)"
      pageTitle="Hydrographic &amp; Impairment Statistics Viewer">
 
 <!-- ArcGIS API 3.0 -->
 <!-- Adobe SDK 4.6 -->
 
 <fx:Style source="defaults.css"/>
 
 <fx:Metadata>
  [ResourceBundle("ViewerStrings")]
 </fx:Metadata>
 
 <fx:Script> 
  <![CDATA[
   
   //import Globals.*;
   import com.esri.ags.FeatureSet;
   import com.esri.ags.Graphic;
   import com.esri.ags.Map;
   import com.esri.ags.geometry.Extent;
   import com.esri.ags.tasks.QueryTask;
   import com.esri.ags.tasks.supportClasses.Query;
   import com.esri.ags.utils.GraphicUtil;
   
//    import com.esri.ags.symbols
   
   import mx.controls.Alert;
   import mx.core.FlexGlobals;
   import mx.events.BrowserChangeEvent;
   import mx.events.FlexEvent;
   import mx.managers.BrowserManager;
   import mx.managers.IBrowserManager;
   import mx.rpc.AsyncResponder;
   import mx.utils.URLUtil;
   
   private var params:Object = null;
   
   private var queryTask:QueryTask = new QueryTask(null);
   private var query:Query = new Query();
   private var featureExtent:Extent = null;
   private var bm:IBrowserManager; 
   
   public var featureSet:FeatureSet
   
   [Bindable]
   private var NPS_List_ID:String = null;
   private var Park:String = null;
   //private var NPS_List_ID:String = "GOGA_CAR2011303020070615132740_OLEMA CREEK";
   [Bindable]
   private var Unit_Code:String;
   private var queryURLS:Array = new Array("http:...rest/services/NRSS/HIS_Dissolved/MapServer/0",
    "http://...rest/services/NRSS/HIS_Dissolved/MapServer/1",
    "http://...rest/services/NRSS/HIS_Dissolved/MapServer/2",
    "http://...rest/services/NRSS/HIS_Dissolved/MapServer/3");
   
   /**
    * Listen application preinitialize handler
    */
   protected function onAppPreinitialize(event:FlexEvent):void
   {
    params = getURLParameters();
    configureQuery();
    /* for (var i:int = 0; i<queryURLS.length; ++i) {
    configureQuery(url);
    } */
   }
   
   private function getURLParameters():Object
   {
    var result:URLVariables = new URLVariables();
    
    try
    {
     if (ExternalInterface.available)
     {
      // Use JavaScript to get the search string from the current browser location.
      // Use substring() to remove leading '?'.
      // See http://livedocs.adobe.com/flex/3/langref/flash/external/ExternalInterface.html
      var search:String = ExternalInterface.call("location.search.substring", 1);
      if (search && search.length > 0)
      {
       result.decode(search);
      }
     }
    }
    catch (error:Error)
    {
     Alert.show(error.toString());
    }
    
    return result;
   }
   
   private function configureQuery():void
   {
    if (params["NPS_List_ID"]) {
     
     // Configure the query task
     queryTask = new QueryTask(null); 
     queryTask.useAMF = false;
     NPS_List_ID = params["NPS_List_ID"];
     // TODO: Need to iterate all layers or add query param based on initial table
     //queryTask.url = queryURLS;
     queryTask.url = "http://...rest/services/NRSS/HIS_Dissolved/MapServer/0";
     
     //new Array("http://...rest/services/NRSS/HIS_Dissolved/MapServer/0",
     //"http://...rest/services/NRSS/HIS_Dissolved/MapServer/1",
     //"http://...rest/services/NRSS/HIS_Dissolved/MapServer/2",
     //"http://...rest/services/NRSS/HIS_Dissolved/MapServer/3");   
     // "http://...rest/services/NRSS/HIS_Dissolved/MapServer/0";  // TODO: SHould be an array
     //dynamically insert the 1, 2, 3, 4 from an array into the url above?
     
     query.where = "NPS_LIST_ID = '" + NPS_List_ID + "'";
     query.returnGeometry = true;
     //     public function SimpleLineSymbol(style:"solid", color: 0xff0000, alpha:1, width:5);
    }
    else if (params["Park"]) {
     // Configure the query task
     queryTask = new QueryTask(null);
     queryTask.useAMF = false;
     Park = params["Park"];
     // TODO: Need to iterate all layers or add query param based on initial table
     //queryTask.url = queryURL
     queryTask.url = "http://...rest/services/NPSData/NPS_Boundaries_WebMercator_labelfree/MapServer/0"; 
     query.where = "UNIT_CODE = '" + Park + "'";
     query.returnGeometry = true;
     //     public function SimpleLineSymbol(style:"solid", color: 0xff0000, alpha:1, width:5);
    }
    else 
    {trace("ERROR: NPS_List_ID or Park not detected."); }
   }
   
   private function queryPark():void
   {
    queryTask = new QueryTask(null);
    queryTask.useAMF = false;
    queryTask.url = "http://...rest/services/NPSData/NPS_Boundaries_WebMercator_labelfree/MapServer/0";
    query.where = "UNIT_CODE = '"+ Globals.Unit_Code +"'";
    query.returnGeometry = true;
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     trace("Number of features: " + featureSet.features.length); 
     // Set map extent to extent of Park features
     var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features); // GraphicUtil.getGraphicsExtent(queryURLS:Array);
     if (graphicsExtent)
     {
      trace(mapManager.map.extent);
      trace(graphicsExtent);
      //Zoom out by 25%
      mapManager.map.extent = graphicsExtent.expand(1.5);
      trace(mapManager.map.extent);
     }
    }
    function onFault(info:Object, token:Object = null):void
    {
     trace("query issue");
     Alert.show(info.toString(), "ERROR: Problem querying park extent from service.");
    }
   }
   
   protected function onMapCreationComplete(event:FlexEvent):void
   {
    if (params["NPS_List_ID"] != null)
    {
     // Execute serivce query for impairment
     // queryTask.execute(query, new AsyncResponder(onResult, onFault));
     queryTask.execute(query, new AsyncResponder(onResult, onFault));
     // Extract unit code from NPS_List_ID
     Unit_Code = NPS_List_ID.substring(0,4);
     Globals.Unit_Code = Unit_Code;
     Globals.NPS_List_ID = params["NPS_List_ID"];
    }
    else if (params["Park"] != null) 
    {
     queryTask.execute(query, new AsyncResponder(onResult, onFault));
     //Extract unit code from NPS_List_ID
     //Unit_Code = NPS_List_ID.substring(0,4);
     //Globals.Unit_Code = Unit_Code;
    }
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     trace("Number of features: " + featureSet.features.length); 
     // Set map extent to extent of NPS_List_ID features
     var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features); // GraphicUtil.getGraphicsExtent(queryURLS:Array);
     if (graphicsExtent)
     {
      //trace(mapManager.map.extent);
      //trace(graphicsExtent);
      //Zoom out by 25%
      mapManager.map.extent = graphicsExtent.expand(1.5);
      //trace(mapManager.map.extent);
     }
    }
    function onFault(info:Object, token:Object = null):void
    {
     //trace("query issue");
     Alert.show(info.toString(), "ERROR: Problem querying impairment from service.");
    }
    
   }
  ]]> 
 </fx:Script>
 
 <viewer:ViewerContainer id="viewerContainer">
  <viewer:configManager>
   <managers:ConfigManager id="configManager"/>
  </viewer:configManager>
  <viewer:dataManager>
   <managers:DataManager id="dataManager"/>
  </viewer:dataManager>
  <viewer:mapManager>
   <managers:MapManager id="mapManager"/>
  </viewer:mapManager>
  <viewer:uiManager>
   <managers:UIManager id="uiManager"/>
  </viewer:uiManager>
  <viewer:widgetManager>
   <managers:WidgetManager id="widgetManager"/>
  </viewer:widgetManager>
 </viewer:ViewerContainer>
 
</s:Application>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Michelle,


   I don't see anywhere in the code that you even need that import at all as there is no code using symbols. Try deleting that line all together.
0 Kudos
MichelleKinseth
Emerging Contributor
Michelle,


   I don't see anywhere in the code that you even need that import at all as there is no code using symbols. Try deleting that line all together.


Hi Robert, thank you for all your help. I just removed the aforementioned line of code and it doesn't seem to be affecting anything.

After upgrading to the new version (3.0.9) of the widget I was able to disable the popups as well as stop the results of a search from appearing in the widget gui. However, I am now getting no search or relate results to show in the fixed data table after performing a search from the widget. I don't even have a "Results" tab showing in the table. I wonder if when I commented out all the "showStateResults" in each of the search functions that I accidentally commented out one that I wasn't supposed too...would that prevent results from populating the data table or are the two (the widget gui and the data table) mutually exclusive in the code?

All my map services are related to their respective tables, and the search/relates results works in the previous version (Flex v2.5, eSearch v2.5) which is using the same services. (would updating the code from 2.5 to 3.0.9 be causing an issue? I skipped a lot of intermediate versions). Sorry if these are silly questions; I'm still struggling to wrap my mind around how Flex works...

I can start a new thread if needed. Thanks so much.

Michelle
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Michelle,

   So when you say
I just removed the  aforementioned line of code and it doesn't seem to be affecting  anything.
Do you mean that you still get the first error image you provided or is it only the second error image now?
0 Kudos
MichelleKinseth
Emerging Contributor
Michelle,

   So when you say  Do you mean that you still get the first error image you provided or is it only the second error image now?


Sorry, I was unclear. That error was resolved when I removed that line, and there are no other problems or errors in the index.mxml now. I had several other issues that I resolved and now everything is working fine, except I am not getting any search results or related information in the widget's fixed table.

What I get, after selecting a feature with the Enhanced Search Widget...
[ATTACH=CONFIG]18021[/ATTACH]
0 Kudos