Skip to content

Commit

Permalink
Clean up SingleLineSearch.
Browse files Browse the repository at this point in the history
* Rename variables.

* Inline method.
  • Loading branch information
jcfranco committed Feb 26, 2013
1 parent 59605e6 commit 91f5f86
Showing 1 changed file with 27 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
private const SINGLE_LINE_SEARCH:String = "SingleLineSearch";
private const DEFAULT_LOCATOR_URL:String = "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer";
private var searchLayersConfigured:Boolean;
private var locatorConfigured:Boolean;
private var mapServicesConfigured:Boolean;
private var locatorServicesConfigured:Boolean;
private var zoomScale:Number = 10000;
private var resultSimpleMarkerSymbol:SimpleMarkerSymbol;
private var resultSimpleLineSymbol:SimpleLineSymbol;
Expand Down Expand Up @@ -120,16 +120,16 @@
configureResultGraphic();
configureLocatorServices();
configureFindServices();
configureMapServices();
}
}
private function configureLocatorServices():void
{
var isGeocodeEnabled:Boolean = (configXML.geocoding.@enabled[0] != "false");
if (!isGeocodeEnabled)
var locatorServicesEnabled:Boolean = (configXML.geocoding.@enabled[0] != "false");
if (!locatorServicesEnabled)
{
locatorConfigured = true;
locatorServicesConfigured = true;
return;
}
Expand Down Expand Up @@ -157,19 +157,19 @@
locatorService));
}
private function locatorInfoRequest_resultHandler(addressFieldData:Object, locatorService:GeocoderLocatorService):void
private function locatorInfoRequest_resultHandler(locatorInfo:Object, locatorService:GeocoderLocatorService):void
{
if (addressFieldData.singleLineAddressField)
if (locatorInfo.singleLineAddressField)
{
locatorService.singleLineAddressFieldName = addressFieldData.singleLineAddressField.name;
locatorService.singleLineAddressFieldName = locatorInfo.singleLineAddressField.name;
}
else
{
showError(hostBaseWidget.getDefaultString("singleLineGeocodingNotSupportedError"), SINGLE_LINE_SEARCH);
}
geocoder.locatorServices = [ locatorService ];
locatorConfigured = true;
locatorServicesConfigured = true;
invalidateProperties();
}
Expand All @@ -180,43 +180,43 @@
ErrorMessageUtil.getKnownErrorCauseMessage(fault),
ErrorMessageUtil.makeHTMLSafe(fault.toString()));
showError(errorMessage, SINGLE_LINE_SEARCH);
locatorConfigured = true;
locatorServicesConfigured = true;
invalidateProperties();
}
private function configureFindServices():void
private function configureMapServices():void
{
var isFindEnabled:Boolean =
var mapServicesEnabled:Boolean =
configXML.searchlayers.@enabled[0] != "false" && configXML.searchlayers[0] != null;
if (isFindEnabled)
if (mapServicesEnabled)
{
if (configXML.searchlayers.length() > 0)
{
var findService:GeocoderMapService;
var findServices:Array = [];
var mapService:GeocoderMapService;
var mapServices:Array = [];
for each (var layerInfo:XML in configXML.searchlayers.searchlayer)
for each (var searchLayerXML:XML in configXML.searchlayers.searchlayer)
{
findService = new GeocoderMapService();
findService.layerIds = layerInfo.layerids.toString().split(",");
findService.url = layerInfo.url.toString();
findService.searchFields = layerInfo.searchfields.toString().split(",");
mapService = new GeocoderMapService();
mapService.layerIds = searchLayerXML.layerids.toString().split(",");
mapService.url = searchLayerXML.url.toString();
mapService.searchFields = searchLayerXML.searchfields.toString().split(",");
if (useProxy && configData.proxyUrl)
{
findService.proxyURL = configData.proxyUrl;
mapService.proxyURL = configData.proxyUrl;
}
findServices.push(findService);
mapServices.push(mapService);
}
geocoder.mapServices = findServices;
geocoder.mapServices = mapServices;
}
}
searchLayersConfigured = true;
mapServicesConfigured = true;
invalidateProperties();
}
Expand Down Expand Up @@ -282,27 +282,22 @@
{
super.commitProperties();
if (locatorConfigured && searchLayersConfigured)
if (locatorServicesConfigured && mapServicesConfigured)
{
configureSearchInput();
}
}
private function configureSearchInput():void
{
const urlSearchTerm:String = getURLSearchTerm();
const urlSearchTerm:String = ViewerContainer.urlConfigParams.search;
if (urlSearchTerm)
{
geocoder.text = urlSearchTerm;
geocoder.search();
}
}
private function getURLSearchTerm():String
{
return ViewerContainer.urlConfigParams.search;
}
//assumes search result SR compatible with map's
private function showSearchResultOnMap(searchResult:GeocoderSearchResult):void
{
Expand Down

0 comments on commit 91f5f86

Please sign in to comment.