From a7711fc5b3c4eacb5a322675a7edf09c520764e3 Mon Sep 17 00:00:00 2001 From: jcfranco Date: Tue, 5 Feb 2013 18:14:52 -0800 Subject: [PATCH 1/8] Defer SingleLineSearch logic to Geocoder component (requires ArcGIS API for Flex 3.2). --- .../singleLineSearch/SingleLineSearch.mxml | 788 ++++-------------- 1 file changed, 148 insertions(+), 640 deletions(-) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml index c08c883..f448c82 100644 --- a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml @@ -19,15 +19,16 @@ + xmlns:components="com.esri.ags.components.*"> 0) + { + useProxy = configXML.useproxy == "true"; + } + const configZoomScale:Number = parseFloat(configXML.zoomscale[0]); if (configZoomScale > 0) { @@ -153,89 +110,73 @@ } const configMinScore:Number = parseFloat(configXML.geocoding.minscore[0]); - if (configMinScore > 0) - { - minscore = configMinScore; - } + geocoder.minScore = (configMinScore > 0) ? configMinScore : 40; - searchPrompt = configXML.labels.searchprompt[0] || hostBaseWidget.getDefaultString("searchPrompt"); - noResultsFoundLabel = configXML.labels.noresults[0] || hostBaseWidget.getDefaultString("noResultsFoundLabel"); + geocoder.prompt = configXML.labels.searchprompt[0] || hostBaseWidget.getDefaultString("searchPrompt"); + geocoder.noResultsText = configXML.labels.noresults[0] || hostBaseWidget.getDefaultString("noResultsFoundLabel"); searchResultTitleLabel = configXML.labels.searchresulttitle[0] || hostBaseWidget.getDefaultString("searchResultTitleLabel"); configureResultSymbols(); configureResultGraphic(); - importSearchResultHistory(); - - isGeocodeEnabled = (configXML.geocoding.@enabled[0] != "false"); - if (isGeocodeEnabled) - { - configureLocator(); - } - - isFindEnabled = (configXML.searchlayers.@enabled[0] != "false" && configXML.searchlayers[0] != null); - if (isFindEnabled) - { - configureSearchLayers(); - } + configureLocatorServices(); + configureFindServices(); } } - private function configureLocator():void + private function configureLocatorServices():void { - const url:String = configXML.geocoding.locator[0] || DEFAULT_LOCATOR_URL; - - if (configXML.useproxy.length() > 0) + var isGeocodeEnabled:Boolean = (configXML.geocoding.@enabled[0] != "false"); + if (!isGeocodeEnabled) { - useProxy = configXML.useproxy == "true"; + locatorConfigured = true; + return; } - const locatorService:JSONTask = new JSONTask(); + const url:String = configXML.geocoding.locator[0] || DEFAULT_LOCATOR_URL; + + var locatorService:GeocoderLocatorService = new GeocoderLocatorService(); locatorService.url = url; - locator.url = url; + locatorService.outFields = [ "Ymax", "Ymin", "Xmax", "Xmin" ]; + + const locatorInfoRequest:JSONTask = new JSONTask(); + locatorInfoRequest.url = url; if (useProxy && configData.proxyUrl) { locatorService.proxyURL = configData.proxyUrl; - locator.proxyURL = configData.proxyUrl; + locatorInfoRequest.proxyURL = configData.proxyUrl; } var urlVars:URLVariables = new URLVariables(); urlVars.f = "json"; - locatorService.execute(urlVars, new AsyncResponder(locatorService_resultHandler, locatorService_faultHandler)); + locatorInfoRequest.execute(urlVars, + new AsyncResponder(locatorInfoRequest_resultHandler, + locatorInfoRequest_faultHandler, + locatorService)); } - private function locatorService_resultHandler(addressFieldData:Object, token:Object = null):void + private function locatorInfoRequest_resultHandler(addressFieldData:Object, locatorService:GeocoderLocatorService):void { if (addressFieldData.singleLineAddressField) { - singleAddressFieldName = addressFieldData.singleLineAddressField.name; + locatorService.singleLineAddressFieldName = addressFieldData.singleLineAddressField.name; } else { showError(hostBaseWidget.getDefaultString("singleLineGeocodingNotSupportedError"), SINGLE_LINE_SEARCH); } + geocoder.locatorServices = [ locatorService ]; locatorConfigured = true; invalidateProperties(); } - override protected function commitProperties():void - { - super.commitProperties(); - - if (isGeocodeEnabled && locatorConfigured - || (isFindEnabled && searchLayersConfigured)) - { - configureSearchInput(); - } - } - - private function locatorService_faultHandler(fault:Fault, token:Object = null):void + private function locatorInfoRequest_faultHandler(fault:Fault, locatorService:GeocoderLocatorService):void { const errorMessage:String = hostBaseWidget.getDefaultString("locatorServiceConnectionError", - locator.url, + locatorService.url, ErrorMessageUtil.getKnownErrorCauseMessage(fault), ErrorMessageUtil.makeHTMLSafe(fault.toString())); showError(errorMessage, SINGLE_LINE_SEARCH); @@ -243,24 +184,35 @@ invalidateProperties(); } - private function showError(message:String, title:String = null):void + private function configureFindServices():void { - _hostBaseWidget.showError(message, title); - } + var isFindEnabled:Boolean = + configXML.searchlayers.@enabled[0] != "false" && configXML.searchlayers[0] != null; - private function configureSearchLayers():void - { - if (configXML.searchlayers.length() > 0) + if (isFindEnabled) { - var searchLayer:SearchLayer; - for each (var layerInfo:XML in configXML.searchlayers.searchlayer) + + if (configXML.searchlayers.length() > 0) { - searchLayer = new SearchLayer(); - searchLayer.layerIds = layerInfo.layerids.toString().split(","); - searchLayer.layerURL = layerInfo.url.toString(); - searchLayer.searchFields = layerInfo.searchfields.toString().split(","); + var findService:GeocoderMapService; + var findServices:Array = []; + + for each (var layerInfo: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(","); - searchLayers.push(searchLayer); + if (useProxy && configData.proxyUrl) + { + findService.proxyURL = configData.proxyUrl; + } + + findServices.push(findService); + } + + geocoder.mapServices = findServices; } } @@ -326,16 +278,13 @@ map.defaultGraphicsLayer.remove(searchResultGraphic); } - private function importSearchResultHistory():void + override protected function commitProperties():void { - try - { - searchResultHistory.importHistory - (searchResultHistoryStorage.data.searchResultHistory as Array); - } - catch (err:Error) + super.commitProperties(); + + if (locatorConfigured && searchLayersConfigured) { - //ignore + configureSearchInput(); } } @@ -344,8 +293,8 @@ const urlSearchTerm:String = getURLSearchTerm(); if (urlSearchTerm) { - searchTerm = urlSearchTerm; - search(); + geocoder.text = urlSearchTerm; + geocoder.search(); } } @@ -354,203 +303,115 @@ return ViewerContainer.urlConfigParams.search; } - private function search():void + //assumes search result SR compatible with map's + private function showSearchResultOnMap(searchResult:GeocoderSearchResult):void { - if (!searchTerm || (!isGeocodeEnabled && !isFindEnabled)) + if (!searchResult) { return; } - currentState = "searching"; + searchResultGraphic.geometry = searchResult.geometry; + searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); + var resultExtent:Extent = searchResult.extent; - const hasCurrentSearchInProgress:Boolean = totalResultsToProcess > 0; - if (hasCurrentSearchInProgress) - { - cursorManager.removeBusyCursor(); - } + const popUpInfo:PopUpInfo = new PopUpInfo(); + popUpInfo.description = searchResult.label; + popUpInfo.title = searchResultTitleLabel; + popUpInfo.showZoomToButton = false; //hide the zoom to button as map would be zoomed-in - cursorManager.setBusyCursor(); - map.infoWindow.hide(); - totalResultsToProcess = 0; - searchResults.removeAll(); + const infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer); + infoWindowRenderer.properties = { popUpInfo: popUpInfo }; + searchResultGraphic.infoWindowRenderer = infoWindowRenderer; - lastSearchTimestamp = getTimer(); + popUpRenderer.popUpInfo = popUpInfo; + popUpRenderer.graphic = searchResultGraphic; - if (isGeocodeEnabled) + map.defaultGraphicsLayer.remove(searchResultGraphic); + if (searchResultGraphic.symbol) { - totalResultsToProcess++; - - const addressData:Object = {}; - addressData[singleAddressFieldName] = searchTerm; - var locatorParams:AddressToLocationsParameters = new AddressToLocationsParameters(); - locatorParams.address = addressData; - locatorParams.outFields = [ "Ymax", "Ymin", "Xmax", "Xmin" ]; - locatorParams.location = map.extent.center; - locatorParams.distance = calculateExtentRadius(); - - locator.addressToLocations(locatorParams, new AsyncResponder(locator_resultHandler, locator_faultHandler, lastSearchTimestamp)); + map.defaultGraphicsLayer.add(searchResultGraphic); } - if (isFindEnabled) - { - totalResultsToProcess += searchLayers.length; + const resultPoint:MapPoint = getGeometryCenter(searchResultGraphic.geometry); - var searchLayer:SearchLayer; - for (var i1:Number = 0; i1 < searchLayers.length; i1++) - { - searchLayer = searchLayers[i1]; - findTask.url = searchLayer.layerURL; - var findParams:FindParameters = new FindParameters(); - findParams.contains = true; - findParams.layerIds = searchLayer.layerIds; - findParams.searchFields = searchLayer.searchFields; - findParams.searchText = searchTerm; - findParams.outSpatialReference = map.spatialReference; - findParams.returnGeometry = true; - - findTask.execute(findParams, new AsyncResponder(findTask_resultHandler, findTask_faultHandler, lastSearchTimestamp)); - } + if (resultExtent) + { + map.zoomTo(resultExtent); } - } - - private function calculateExtentRadius():Number - { - var radius:Number; - - if (map.spatialReference.wkid == 4326 - || map.spatialReference.isWebMercator()) + else { - const currentExtent:Extent = map.extent; - var diagonal:Polyline = new Polyline([[ new MapPoint(currentExtent.xmin, currentExtent.ymin), - new MapPoint(currentExtent.xmax, currentExtent.ymax)]]); - - if (map.spatialReference.isWebMercator()) + if (searchResultGraphic.geometry.type == Geometry.MAPPOINT) { - diagonal = WebMercatorUtil.webMercatorToGeographic(diagonal) as Polyline; + if (map.scale > zoomScale) + { + map.scale = zoomScale; + } } - const diagonalLength:Number = GeometryUtil.geodesicLengths([ diagonal ], Units.METERS)[0]; - - radius = Math.round(diagonalLength * 0.5); + map.zoomTo(searchResultGraphic.geometry); } - return radius; + infoWindowShow(resultPoint); } - private function locator_resultHandler(results:Array, searchTimestamp:int):void + private function getSymbolForGeometryType(geometryType:String):Symbol { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } + var symbol:Symbol; - for each (var addressCandidate:AddressCandidate in results) + switch (geometryType) { - if (addressCandidate.score >= minscore) + case Geometry.POLYLINE: + { + symbol = resultSimpleLineSymbol; + break; + } + case Geometry.POLYGON: { - searchResults.addItem(addressCandidate); + symbol = resultSimpleFillSymbol; + break; + } + case Geometry.MAPPOINT: + default: + { + symbol = resultSimpleMarkerSymbol; } } - decreaseProcessedResultCount(); - } - - private function decreaseProcessedResultCount():void - { - totalResultsToProcess--; - - if (totalResultsToProcess == 0) - { - showSearchResults(); - } + return symbol; } - private function showSearchResults():void + private function getGeometryCenter(geometry:Geometry):MapPoint { - cursorManager.removeBusyCursor(); + var center:MapPoint; - if (searchResults.length > 1) - { - currentState = "showingSearchResults"; - resultList.selectedIndex = -1; - } - else if (searchResults.length == 1) + if (geometry is MapPoint) { - storeSearchResult(searchResults.getItemAt(0)); - var searchResult:Object = getSearchResult(searchResults.getItemAt(0)); - searchTerm = searchResult.label; - projectToMapSpatialReferenceAndShowResultOnMap(searchResult); + center = geometry as MapPoint; } - else + else if (geometry) { - currentState = "noResults"; + center = geometry.extent.center; } - } - - private function storeSearchResult(searchResult:Object):void - { - searchResultHistory.addItem(searchResult); - exportSearchResultHistory(); - } - private function exportSearchResultHistory():void - { - try - { - searchResultHistoryStorage.data.searchResultHistory = - searchResultHistory.exportHistory(); - searchResultHistoryStorage.flush(); - } - catch (err:Error) - { - //ignore - } + return center; } - private function getSearchResult(searchResult:Object):Object + private function infoWindowShow(point:MapPoint):void { - var result:Object; - - if (searchResult is FindResult) - { - result = {}; - const findResult:FindResult = searchResult as FindResult; - result.label = findResult.value; - result.geometry = findResult.feature.geometry; - result.extent = null; - } - else if (searchResult is AddressCandidate) - { - result = {}; - const addressCandidate:AddressCandidate = searchResult as AddressCandidate; - result.label = addressCandidate.address; - result.geometry = addressCandidate.location; - result.extent = getGeographicResultExtent(addressCandidate); - } - - return result; + map.infoWindow.content = popUpRenderer; + map.infoWindow.contentOwner = popUpRenderer.graphic; + map.infoWindow.show(point); } - private function getGeographicResultExtent(addressCandidate:AddressCandidate):Extent + protected function geocoder_searchCompleteHandler(event:GeocoderEvent):void { - const canCreateResultExtent:Boolean = addressCandidate - && addressCandidate.attributes - && Boolean(addressCandidate.attributes.Xmin) && Boolean(addressCandidate.attributes.Ymin) - && Boolean(addressCandidate.attributes.Xmax) && Boolean(addressCandidate.attributes.Ymax) - && !isNaN(addressCandidate.attributes.Xmin) && !isNaN(addressCandidate.attributes.Ymin) - && !isNaN(addressCandidate.attributes.Xmax) && !isNaN(addressCandidate.attributes.Ymax); - - return canCreateResultExtent ? new Extent(addressCandidate.attributes.Xmin, - addressCandidate.attributes.Ymin, - addressCandidate.attributes.Xmax, - addressCandidate.attributes.Ymax, - new SpatialReference(4326)) : null; + projectToMapSpatialReferenceAndShowResultOnMap(event.searchResult); } - private function projectToMapSpatialReferenceAndShowResultOnMap(searchResult:Object):void + private function projectToMapSpatialReferenceAndShowResultOnMap(searchResult:GeocoderSearchResult):void { var needToProjectGeometryServerSide:Boolean; - if (map.spatialReference.isWebMercator() && searchResult.geometry.spatialReference && searchResult.geometry.spatialReference.wkid == 4326) @@ -569,13 +430,12 @@ } var needToProjectExtentServerSide:Boolean; - if (searchResult.extent) { if (map.spatialReference.isWebMercator() && searchResult.extent.spatialReference.wkid == 4326) { - searchResult.extent = WebMercatorUtil.geographicToWebMercator(searchResult.extent); + searchResult.extent = WebMercatorUtil.geographicToWebMercator(searchResult.extent) as Extent; } else if (map.spatialReference.wkid == 4326 && searchResult.extent.spatialReference @@ -590,7 +450,6 @@ } var previousShowBusyCursorValue:Boolean = GeometryServiceSingleton.instance.showBusyCursor; - if (needToProjectGeometryServerSide) { projectGeometryServerSide(); @@ -609,7 +468,6 @@ var projectionParams:ProjectParameters = new ProjectParameters(); projectionParams.geometries = [ searchResult.geometry ]; projectionParams.outSpatialReference = map.spatialReference; - GeometryServiceSingleton.instance.showBusyCursor = true; GeometryServiceSingleton.instance.project( projectionParams, new AsyncResponder(projectGeometryResultHandler, @@ -619,7 +477,6 @@ function projectGeometryResultHandler(geometry:Array, token:Object = null):void { searchResult.geometry = geometry[0]; - if (needToProjectExtentServerSide) { projectExtentServerSide(); @@ -635,7 +492,6 @@ var projectionParams:ProjectParameters = new ProjectParameters(); projectionParams.geometries = [ searchResult.extent ]; projectionParams.outSpatialReference = map.spatialReference; - GeometryServiceSingleton.instance.showBusyCursor = true; GeometryServiceSingleton.instance.project( projectionParams, new AsyncResponder(projectExtentResultHandler, @@ -651,10 +507,8 @@ function handleProjectionComplete():void { GeometryServiceSingleton.instance.showBusyCursor = previousShowBusyCursorValue; - var resultHasValidGeometry:Boolean = hasValidGeometry(searchResult.geometry); var resultHasExtentAndIsValid:Boolean = searchResult.extent && hasValidGeometry(searchResult.extent); - if (resultHasExtentAndIsValid && resultHasValidGeometry || resultHasValidGeometry) { @@ -676,7 +530,6 @@ private function hasValidGeometry(geometry:Geometry):Boolean { var isValid:Boolean; - if (geometry) { if (geometry.type == Geometry.MAPPOINT) @@ -700,7 +553,6 @@ isValid = isValidPolyline(geometry as Polyline); } } - return isValid; } @@ -717,11 +569,9 @@ private function hasValidMapPoints(points:Array):Boolean { var isValid:Boolean; - if (points && points.length > 0) { isValid = true; - for each (var point:MapPoint in points) { if (!isValidMapPoint(point)) @@ -731,18 +581,15 @@ } } } - return isValid; } private function isValidPolyline(polyline:Polyline):Boolean { var isValid:Boolean; - if (polyline && polyline.paths && polyline.paths.length > 0) { isValid = true; - for each (var path:Array in polyline.paths) { if (!hasValidMapPoints(path)) @@ -752,18 +599,15 @@ } } } - return isValid; } private function isValidPolygon(polygon:Polygon):Boolean { var isValid:Boolean; - if (polygon && polygon.rings && polygon.rings.length > 0) { isValid = true; - for each (var ring:Array in polygon.rings) { if (!hasValidMapPoints(ring)) @@ -773,363 +617,27 @@ } } } - return isValid; } - private function locator_faultHandler(info:Object, searchTimestamp:int):void - { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } - - showError(info.toString(), SINGLE_LINE_SEARCH); - decreaseProcessedResultCount(); - } - - private function findTask_resultHandler(results:Array, searchTimestamp:int):void - { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } - - for each (var findResult:FindResult in results) - { - searchResults.addItem(findResult); - } - - decreaseProcessedResultCount(); - } - - private function findTask_faultHandler(error:Fault, searchTimestamp:int):void - { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } - - decreaseProcessedResultCount(); - } - - private function processSelectedSearchResult():void - { - if (resultList.selectedItem) - { - storeSearchResult(resultList.selectedItem); - var searchResult:Object = getSearchResult(resultList.selectedItem); - searchTerm = searchResult.label; - projectToMapSpatialReferenceAndShowResultOnMap(searchResult); - resetSearchResultSelection(); - } - } - - private function resetSearchResultSelection():void + protected function geocoder_faultHandler(event:FaultEvent):void { - resultList.dataProvider.removeAll(); - currentState = "normal"; + showError(ErrorMessageUtil.buildFaultMessage(event.fault), SINGLE_LINE_SEARCH); } - //assumes search result SR compatible with map's - private function showSearchResultOnMap(searchResult:Object):void - { - if (!searchResult) - { - return; - } - - searchResultGraphic.geometry = searchResult.geometry; - searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); - var resultExtent:Extent = searchResult.extent; - - const popUpInfo:PopUpInfo = new PopUpInfo(); - popUpInfo.description = searchResult.label; - popUpInfo.title = searchResultTitleLabel; - popUpInfo.showZoomToButton = false; //hide the zoom to button as map would be zoomed-in - - const infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer); - infoWindowRenderer.properties = { popUpInfo: popUpInfo }; - searchResultGraphic.infoWindowRenderer = infoWindowRenderer; - - popUpRenderer.popUpInfo = popUpInfo; - popUpRenderer.graphic = searchResultGraphic; - - map.defaultGraphicsLayer.remove(searchResultGraphic); - if (searchResultGraphic.symbol) - { - map.defaultGraphicsLayer.add(searchResultGraphic); - } - - const resultPoint:MapPoint = getGeometryCenter(searchResultGraphic.geometry); - - if (resultExtent) - { - map.zoomTo(resultExtent); - } - else - { - if (searchResultGraphic.geometry.type == Geometry.MAPPOINT) - { - if (map.scale > zoomScale) - { - map.scale = zoomScale; - } - } - - map.zoomTo(searchResultGraphic.geometry); - } - - infoWindowShow(resultPoint); - } - - private function getSymbolForGeometryType(geometryType:String):Symbol - { - var symbol:Symbol; - - switch (geometryType) - { - case Geometry.POLYLINE: - { - symbol = resultSimpleLineSymbol; - break; - } - case Geometry.POLYGON: - { - symbol = resultSimpleFillSymbol; - break; - } - case Geometry.MAPPOINT: - default: - { - symbol = resultSimpleMarkerSymbol; - } - } - - return symbol; - } - - private function getGeometryCenter(geometry:Geometry):MapPoint - { - var center:MapPoint; - - if (geometry is MapPoint) - { - center = geometry as MapPoint; - } - else if (geometry) - { - center = geometry.extent.center; - } - - return center; - } - - private function infoWindowShow(point:MapPoint):void - { - map.infoWindow.content = popUpRenderer; - map.infoWindow.contentOwner = popUpRenderer.graphic; - map.infoWindow.show(point); - } - - protected function searchInput_focusInHandler(event:FocusEvent):void - { - if (currentState == "normal") - { - if (searchResults.length > 1) - { - currentState = "showingSearchResults"; - resultList.selectedIndex = -1; - } - else - { - processSearchResult(); - } - } - } - - protected function this_focusOutHandler(event:FocusEvent):void - { - if (event.relatedObject == resultList - || event.relatedObject == searchInput) - { - return; - } - - if (currentState != "searching") - { - currentState = "normal"; - } - } - - protected function searchInput_changeHandler(event:TextOperationEvent):void - { - processSearchResult(); - } - - private function processSearchResult():void - { - if (searchResults.length > 0) - { - searchResults.removeAll(); - } - - const searchResultMatches:Array = searchInHistory(searchTerm); - searchResultHistoryList.source = searchResultMatches; - if (searchResultMatches.length > 0) - { - currentState = "showingPreviousSearchResults"; - resultList.selectedIndex = -1; - } - else - { - currentState = "normal"; - } - } - - private function searchInHistory(input:String):Array - { - const matches:Array = []; - - if (input) - { - input = input.toLowerCase(); - - const searchResultItems:Array = searchResultHistory.items; - var searchResult:Object; - for (var i:int = searchResultItems.length - 1; i >= 0; i--) - { - searchResult = searchResultItems[i]; - - if (searchResult is FindResult && !isFindEnabled - || searchResult is AddressCandidate && !isGeocodeEnabled) - { - continue; - } - - if (SearchResultUtil.searchResultToLabel(searchResult).toLowerCase().indexOf(input) != -1) - { - matches.unshift(searchResult); - if (matches.length >= 10) - { - break; - } - } - } - } - - return matches; - } - - protected function searchInput_keyDownHandler(event:KeyboardEvent):void - { - if (event.keyCode == Keyboard.ESCAPE) - { - currentState = "normal"; - } - - if (event.keyCode == Keyboard.DOWN) - { - processDownKey(); - } - - if (event.keyCode == Keyboard.UP) - { - processUpKey(); - } - } - - private function processUpKey():void - { - if (currentState == "showingPreviousSearchResults" - || currentState == "showingSearchResults") - { - resultList.selectedIndex--; - resultList.ensureIndexIsVisible(resultList.selectedIndex); - } - } - - private function processDownKey():void - { - if (currentState == "showingPreviousSearchResults" - || currentState == "showingSearchResults") - { - resultList.selectedIndex++; - resultList.ensureIndexIsVisible(resultList.selectedIndex); - } - } - - protected function resultList_changeHandler(event:IndexChangeEvent):void - { - if (resultList.selectedIndex > -1) - { - processSelectedSearchResult(); - } - } - - protected function searchInput_enterHandler(event:FlexEvent):void + private function showError(message:String, title:String = null):void { - if (resultList.selectedIndex > -1) - { - processSelectedSearchResult(); - } - else - { - search(); - } + _hostBaseWidget.showError(message, title); } ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - + From 59605e6db564ef053ac5d4e6deab452fc479aa35 Mon Sep 17 00:00:00 2001 From: jcfranco Date: Wed, 6 Feb 2013 12:45:18 -0800 Subject: [PATCH 2/8] Delete unnecessary SingleLineSearch files. --- .../components/singleLineSearch/ResultList.as | 26 -- .../ResultListItemRenderer.mxml | 28 -- .../singleLineSearch/SearchInputSkin.mxml | 288 ------------------ .../singleLineSearch/SearchLayer.as | 25 -- .../singleLineSearch/SearchResultUtil.as | 55 ---- 5 files changed, 422 deletions(-) delete mode 100644 src/com/esri/viewer/components/singleLineSearch/ResultList.as delete mode 100644 src/com/esri/viewer/components/singleLineSearch/ResultListItemRenderer.mxml delete mode 100644 src/com/esri/viewer/components/singleLineSearch/SearchInputSkin.mxml delete mode 100644 src/com/esri/viewer/components/singleLineSearch/SearchLayer.as delete mode 100644 src/com/esri/viewer/components/singleLineSearch/SearchResultUtil.as diff --git a/src/com/esri/viewer/components/singleLineSearch/ResultList.as b/src/com/esri/viewer/components/singleLineSearch/ResultList.as deleted file mode 100644 index 527bacf..0000000 --- a/src/com/esri/viewer/components/singleLineSearch/ResultList.as +++ /dev/null @@ -1,26 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// 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. -/////////////////////////////////////////////////////////////////////////// -package com.esri.viewer.components.singleLineSearch -{ - -import spark.components.List; - -public class ResultList extends List -{ - [Bindable] - public var searchText:String = ""; -} -} diff --git a/src/com/esri/viewer/components/singleLineSearch/ResultListItemRenderer.mxml b/src/com/esri/viewer/components/singleLineSearch/ResultListItemRenderer.mxml deleted file mode 100644 index 064bdec..0000000 --- a/src/com/esri/viewer/components/singleLineSearch/ResultListItemRenderer.mxml +++ /dev/null @@ -1,28 +0,0 @@ - - - - $&"); - suggestionLabel.textFlow = TextConverter.importToFlow(suggestionText, TextConverter.TEXT_FIELD_HTML_FORMAT); - } - ]]> - - - - diff --git a/src/com/esri/viewer/components/singleLineSearch/SearchInputSkin.mxml b/src/com/esri/viewer/components/singleLineSearch/SearchInputSkin.mxml deleted file mode 100644 index 4cd2406..0000000 --- a/src/com/esri/viewer/components/singleLineSearch/SearchInputSkin.mxml +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/esri/viewer/components/singleLineSearch/SearchLayer.as b/src/com/esri/viewer/components/singleLineSearch/SearchLayer.as deleted file mode 100644 index 56e8559..0000000 --- a/src/com/esri/viewer/components/singleLineSearch/SearchLayer.as +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// 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. -/////////////////////////////////////////////////////////////////////////// -package com.esri.viewer.components.singleLineSearch -{ - -public class SearchLayer -{ - public var layerIds:Array; - public var layerURL:String; - public var searchFields:Array; -} -} diff --git a/src/com/esri/viewer/components/singleLineSearch/SearchResultUtil.as b/src/com/esri/viewer/components/singleLineSearch/SearchResultUtil.as deleted file mode 100644 index fe80fdd..0000000 --- a/src/com/esri/viewer/components/singleLineSearch/SearchResultUtil.as +++ /dev/null @@ -1,55 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// 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. -/////////////////////////////////////////////////////////////////////////// -package com.esri.viewer.components.singleLineSearch -{ - -import com.esri.ags.tasks.supportClasses.AddressCandidate; -import com.esri.ags.tasks.supportClasses.FindResult; - -import mx.utils.StringUtil; - -public class SearchResultUtil -{ - public static function searchResultToLabel(searchResult:Object):String - { - if (searchResult is FindResult) - { - return findResultToLabel(searchResult as FindResult); - } - else if (searchResult is AddressCandidate) - { - return (searchResult as AddressCandidate).address as String; - } - else if (searchResult == null) - { - return ""; - } - else - { - return searchResult as String; - } - } - - private static function findResultToLabel(findResult:FindResult):String - { - return StringUtil.substitute('{0} - {1} - {2} ({3})', - findResult.value, - findResult.foundFieldName, - findResult.layerName, - findResult.layerId); - } -} -} From 91f5f86ecaa1cb27210be3c7e2a1ef4f16447e68 Mon Sep 17 00:00:00 2001 From: jcfranco Date: Mon, 11 Feb 2013 21:54:41 -0800 Subject: [PATCH 3/8] Clean up SingleLineSearch. * Rename variables. * Inline method. --- .../singleLineSearch/SingleLineSearch.mxml | 59 +++++++++---------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml index f448c82..8b5dc3b 100644 --- a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml @@ -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; @@ -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; } @@ -157,11 +157,11 @@ 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 { @@ -169,7 +169,7 @@ } geocoder.locatorServices = [ locatorService ]; - locatorConfigured = true; + locatorServicesConfigured = true; invalidateProperties(); } @@ -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(); } @@ -282,7 +282,7 @@ { super.commitProperties(); - if (locatorConfigured && searchLayersConfigured) + if (locatorServicesConfigured && mapServicesConfigured) { configureSearchInput(); } @@ -290,7 +290,7 @@ private function configureSearchInput():void { - const urlSearchTerm:String = getURLSearchTerm(); + const urlSearchTerm:String = ViewerContainer.urlConfigParams.search; if (urlSearchTerm) { geocoder.text = urlSearchTerm; @@ -298,11 +298,6 @@ } } - private function getURLSearchTerm():String - { - return ViewerContainer.urlConfigParams.search; - } - //assumes search result SR compatible with map's private function showSearchResultOnMap(searchResult:GeocoderSearchResult):void { From 5c27940b1d0e9519cb477943081653b3a82b0eae Mon Sep 17 00:00:00 2001 From: jcfranco Date: Mon, 11 Feb 2013 22:21:19 -0800 Subject: [PATCH 4/8] Add support for Geocoder properties. --- .../singleLineSearch/SingleLineSearch.mxml | 65 ++++++++++++++++--- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml index 8b5dc3b..04d17a2 100644 --- a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml @@ -55,10 +55,7 @@ import mx.rpc.events.FaultEvent; private const SINGLE_LINE_SEARCH:String = "SingleLineSearch"; - private const DEFAULT_LOCATOR_URL:String = "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"; - private var mapServicesConfigured:Boolean; - private var locatorServicesConfigured:Boolean; private var zoomScale:Number = 10000; private var resultSimpleMarkerSymbol:SimpleMarkerSymbol; private var resultSimpleLineSymbol:SimpleLineSymbol; @@ -75,6 +72,32 @@ [Bindable] private var searchResultTitleLabel:String; + private var _mapServicesConfigured:Boolean; + + public function get mapServicesConfigured():Boolean + { + return _mapServicesConfigured; + } + + public function set mapServicesConfigured(value:Boolean):void + { + _mapServicesConfigured = value; + invalidateProperties(); + } + + private var _locatorServicesConfigured:Boolean; + + public function get locatorServicesConfigured():Boolean + { + return _locatorServicesConfigured; + } + + public function set locatorServicesConfigured(value:Boolean):void + { + _locatorServicesConfigured = value; + invalidateProperties(); + } + private var _hostBaseWidget:BaseWidget; public function get hostBaseWidget():BaseWidget @@ -109,9 +132,30 @@ zoomScale = configZoomScale; } - const configMinScore:Number = parseFloat(configXML.geocoding.minscore[0]); + //backwards compatibility + const configMinScore:Number = parseFloat(configXML.minscore[0]) || parseFloat(configXML.geocoding.minscore[0]); geocoder.minScore = (configMinScore > 0) ? configMinScore : 40; + geocoder.autoComplete = configXML.autocomplete != "false"; + + const configMaxLocations:int = parseInt(configXML.maxlocations[0]) + if (!isNaN(configMaxLocations) && configMaxLocations > 0) + { + geocoder.maxLocations = configMaxLocations; + } + + const configMinChars:int = parseInt(configXML.minchars[0]) + if (configMinChars && configMinChars > 0) + { + geocoder.minCharacters = configMinChars; + } + + const configSearchDelay:int = parseInt(configXML.searchdelay[0]) + if (configSearchDelay && configSearchDelay > 0) + { + geocoder.searchDelay = configSearchDelay; + } + geocoder.prompt = configXML.labels.searchprompt[0] || hostBaseWidget.getDefaultString("searchPrompt"); geocoder.noResultsText = configXML.labels.noresults[0] || hostBaseWidget.getDefaultString("noResultsFoundLabel"); searchResultTitleLabel = configXML.labels.searchresulttitle[0] || hostBaseWidget.getDefaultString("searchResultTitleLabel"); @@ -133,7 +177,14 @@ return; } - const url:String = configXML.geocoding.locator[0] || DEFAULT_LOCATOR_URL; + const url:String = configXML.geocoding.locator[0]; + + if (!url) + { + geocoder.useDefaultLocator = true; + locatorServicesConfigured = true; + return; + } var locatorService:GeocoderLocatorService = new GeocoderLocatorService(); locatorService.url = url; @@ -170,7 +221,6 @@ geocoder.locatorServices = [ locatorService ]; locatorServicesConfigured = true; - invalidateProperties(); } private function locatorInfoRequest_faultHandler(fault:Fault, locatorService:GeocoderLocatorService):void @@ -181,7 +231,6 @@ ErrorMessageUtil.makeHTMLSafe(fault.toString())); showError(errorMessage, SINGLE_LINE_SEARCH); locatorServicesConfigured = true; - invalidateProperties(); } private function configureMapServices():void @@ -217,7 +266,6 @@ } mapServicesConfigured = true; - invalidateProperties(); } private function configureResultSymbols():void @@ -629,7 +677,6 @@ Date: Mon, 11 Feb 2013 22:25:31 -0800 Subject: [PATCH 5/8] Add support for GeocoderMapService properties. --- .../components/singleLineSearch/SingleLineSearch.mxml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml index 04d17a2..671c507 100644 --- a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml @@ -240,11 +240,11 @@ if (mapServicesEnabled) { - if (configXML.searchlayers.length() > 0) { var mapService:GeocoderMapService; var mapServices:Array = []; + var mapServiceProxyURL:String; for each (var searchLayerXML:XML in configXML.searchlayers.searchlayer) { @@ -252,10 +252,12 @@ mapService.layerIds = searchLayerXML.layerids.toString().split(","); mapService.url = searchLayerXML.url.toString(); mapService.searchFields = searchLayerXML.searchfields.toString().split(","); + mapService.name = searchLayerXML.name.toString(); + mapServiceProxyURL = searchLayerXML.proxyurl.toString() || configData.proxyUrl; - if (useProxy && configData.proxyUrl) + if (useProxy && mapServiceProxyURL) { - mapService.proxyURL = configData.proxyUrl; + mapService.proxyURL = mapServiceProxyURL; } mapServices.push(mapService); From 4b7b547a8d605784a4fee89e3d15a7ef618124b4 Mon Sep 17 00:00:00 2001 From: jcfranco Date: Mon, 11 Feb 2013 22:46:17 -0800 Subject: [PATCH 6/8] Add support for GeocoderLocatorService properties. --- .../singleLineSearch/SingleLineSearch.mxml | 128 ++++++++++++------ 1 file changed, 87 insertions(+), 41 deletions(-) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml index 671c507..fa1dc7b 100644 --- a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml @@ -177,60 +177,106 @@ return; } - const url:String = configXML.geocoding.locator[0]; - - if (!url) + if (!configXML.geocoding.locator[0]) { geocoder.useDefaultLocator = true; locatorServicesConfigured = true; return; } + //backwards compatibility + else if (configXML.geocoding.locator.hasSimpleContent()) + { + //convert URL to locator XML + var url:String = configXML.geocoding.locator[0]; + delete configXML.geocoding.locator[0]; + configXML.geocoding.appendChild({url}); + } - var locatorService:GeocoderLocatorService = new GeocoderLocatorService(); - locatorService.url = url; - locatorService.outFields = [ "Ymax", "Ymin", "Xmax", "Xmin" ]; - - const locatorInfoRequest:JSONTask = new JSONTask(); - locatorInfoRequest.url = url; + var locatorsToConfigure:int = configXML.geocoding.locator.length(); + var locatorServices:Array = []; + var locatorService:GeocoderLocatorService; - if (useProxy && configData.proxyUrl) + for each (var locatorXML:XML in configXML.geocoding.locator) { - locatorService.proxyURL = configData.proxyUrl; - locatorInfoRequest.proxyURL = configData.proxyUrl; - } + locatorService = new GeocoderLocatorService(); + locatorService.url = locatorXML.url.toString(); + locatorService.name = locatorXML.name.toString(); + locatorService.sourceCountry = locatorXML.sourcecountry.toString(); + locatorService.prefix = locatorXML.prefix.toString(); + locatorService.suffix = locatorXML.suffix.toString(); - var urlVars:URLVariables = new URLVariables(); - urlVars.f = "json"; + var configOutFields:String = locatorXML.outfields.toString(); + if (configOutFields) + { + locatorService.outFields = configOutFields.split(','); + } - locatorInfoRequest.execute(urlVars, - new AsyncResponder(locatorInfoRequest_resultHandler, - locatorInfoRequest_faultHandler, - locatorService)); - } + var locatorServiceProxyURL:String = locatorXML.proxyurl.toString() || configData.proxyUrl; + if (useProxy && locatorServiceProxyURL) + { + locatorService.proxyURL = locatorServiceProxyURL; + } - private function locatorInfoRequest_resultHandler(locatorInfo:Object, locatorService:GeocoderLocatorService):void - { - if (locatorInfo.singleLineAddressField) - { - locatorService.singleLineAddressFieldName = locatorInfo.singleLineAddressField.name; - } - else - { - showError(hostBaseWidget.getDefaultString("singleLineGeocodingNotSupportedError"), SINGLE_LINE_SEARCH); - } + var singleLineAddressField:String = locatorXML.singlelineaddressfield.toString(); + if (singleLineAddressField) + { + locatorService.singleLineAddressFieldName = singleLineAddressField; + locatorServices.push(locatorService); + locatorProcessed(); + } + else + { + const locatorInfoRequest:JSONTask = new JSONTask(); + locatorInfoRequest.url = locatorService.url; + if (useProxy && locatorServiceProxyURL) + { + locatorInfoRequest.proxyURL = locatorService.proxyURL; + } - geocoder.locatorServices = [ locatorService ]; - locatorServicesConfigured = true; - } + var urlVars:URLVariables = new URLVariables(); + urlVars.f = "json"; - private function locatorInfoRequest_faultHandler(fault:Fault, locatorService:GeocoderLocatorService):void - { - const errorMessage:String = hostBaseWidget.getDefaultString("locatorServiceConnectionError", - locatorService.url, - ErrorMessageUtil.getKnownErrorCauseMessage(fault), - ErrorMessageUtil.makeHTMLSafe(fault.toString())); - showError(errorMessage, SINGLE_LINE_SEARCH); - locatorServicesConfigured = true; + locatorInfoRequest.execute(urlVars, + new AsyncResponder(locatorInfoRequest_resultHandler, + locatorInfoRequest_faultHandler, + locatorService)); + + function locatorInfoRequest_resultHandler(locatorInfo:Object, locatorService:GeocoderLocatorService):void + { + if (locatorInfo.singleLineAddressField) + { + locatorService.singleLineAddressFieldName = locatorInfo.singleLineAddressField.name; + } + else + { + showError(hostBaseWidget.getDefaultString("singleLineGeocodingNotSupportedError"), SINGLE_LINE_SEARCH); + } + + locatorServices.push(locatorService); + locatorProcessed(); + } + + function locatorInfoRequest_faultHandler(fault:Fault, locatorService:GeocoderLocatorService):void + { + const errorMessage:String = hostBaseWidget.getDefaultString("locatorServiceConnectionError", + locatorService.url, + ErrorMessageUtil.getKnownErrorCauseMessage(fault), + ErrorMessageUtil.makeHTMLSafe(fault.toString())); + showError(errorMessage, SINGLE_LINE_SEARCH); + locatorProcessed(); + } + } + + function locatorProcessed():void + { + locatorsToConfigure--; + if (locatorsToConfigure == 0) + { + geocoder.locatorServices = locatorServices; + locatorServicesConfigured = true; + } + } + } } private function configureMapServices():void From 0b77d550dcdb8693bdb23f605a56a89efa650d77 Mon Sep 17 00:00:00 2001 From: jcfranco Date: Tue, 12 Feb 2013 11:03:39 -0800 Subject: [PATCH 7/8] Move SingleLineSearch into components package. --- .../{singleLineSearch => }/SingleLineSearch.mxml | 0 src/widgets/HeaderController/HeaderControllerWidget.mxml | 9 ++++----- 2 files changed, 4 insertions(+), 5 deletions(-) rename src/com/esri/viewer/components/{singleLineSearch => }/SingleLineSearch.mxml (100%) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/SingleLineSearch.mxml similarity index 100% rename from src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml rename to src/com/esri/viewer/components/SingleLineSearch.mxml diff --git a/src/widgets/HeaderController/HeaderControllerWidget.mxml b/src/widgets/HeaderController/HeaderControllerWidget.mxml index 2a88653..572f610 100644 --- a/src/widgets/HeaderController/HeaderControllerWidget.mxml +++ b/src/widgets/HeaderController/HeaderControllerWidget.mxml @@ -22,7 +22,6 @@ xmlns:viewer="com.esri.viewer.*" xmlns:components="com.esri.viewer.components.*" xmlns:HeaderController="widgets.HeaderController.*" - xmlns:singleLineSearch="com.esri.viewer.components.singleLineSearch.*" width="100%" borderSkin="{null}" creationComplete="creationCompleteHandler(event)" @@ -477,10 +476,10 @@ - + Date: Fri, 15 Feb 2013 09:54:46 -0800 Subject: [PATCH 8/8] Add support for using default locator (vs. automatically enabling it if no locators provided). --- .../esri/viewer/components/SingleLineSearch.mxml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/com/esri/viewer/components/SingleLineSearch.mxml b/src/com/esri/viewer/components/SingleLineSearch.mxml index fa1dc7b..7398438 100644 --- a/src/com/esri/viewer/components/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/SingleLineSearch.mxml @@ -177,14 +177,14 @@ return; } - if (!configXML.geocoding.locator[0]) + if (configXML.geocoding.@usedefaultlocator[0] != "false") { geocoder.useDefaultLocator = true; - locatorServicesConfigured = true; - return; } + //backwards compatibility - else if (configXML.geocoding.locator.hasSimpleContent()) + if (configXML.geocoding.locator[0] + && configXML.geocoding.locator.hasSimpleContent()) { //convert URL to locator XML var url:String = configXML.geocoding.locator[0]; @@ -193,6 +193,12 @@ } var locatorsToConfigure:int = configXML.geocoding.locator.length(); + if (locatorsToConfigure == 0) + { + locatorServicesConfigured = true; + return; + } + var locatorServices:Array = []; var locatorService:GeocoderLocatorService;