Solved! Go to Solution.
<esri:Geocoder autoComplete="true" url="url here" id="geoCoderID" map="{myMap}"/> protected function application1_creationCompleteHandler(event:FlexEvent):void { geoLO.searchExtent = myMap.extent; geoCoderID.locatorOptions = geoLO; geoCoderID.locatorOptions.outFields = [ "Loc_name" , "Ref_ID" ]; geoCoderID.addEventListener(GeocoderEvent.RESULT_SELECTED,geocoderResultSelected); geoCoderID.addEventListener(GeocoderEvent.SEARCH_AUTO_COMPLETE,geocoderSearchAutoCompleteEventHandler); geoCoderID.addEventListener(GeocoderEvent.SEARCH_COMPLETE, geocoderResultsEvent); } private function geocoderSearchAutoCompleteEventHandler(event:GeocoderEvent):void { var geocoderResultsGraphic:Graphic = new Graphic(); geocoderResultsGraphic.id = "graphicResults"; geocoderResultsGraphic.symbol = geocoderResultSymbol; for(var i:int = 1; i<event.results.length; i++) { geocoderResultsGraphic.geometry = event.results[0].geometry; geocoderResultsGraphic.toolTip = event.results[0].label.toString(); myMap.defaultGraphicsLayer.add(geocoderResultsGraphic); } } //The below function works as intended private function geocoderResultSelected(event:GeocoderEvent):void { landmarkPointX = event.result.data.location.x; landmarkPointY = event.result.data.location.y; landmarkMapPoint = new MapPoint(landmarkPointX,landmarkPointY,null); identifyMapPoint = new MapPoint(landmarkPointX,landmarkPointY,null); myMap.defaultGraphicsLayer.clear(); if(event.result.data.attributes.Loc_name == "LandmarkCom.ELandmarkAll" || event.result.data.attributes.Loc_name == "LandmarkCom.ELandmarkName") { queryLandmarks.where = "OBJECTID="+ event.result.data.attributes.Ref_ID; queryTaskLandmarks.execute(queryLandmarks, new AsyncResponder(catchLandmarkGeocoderDetails, onURLLoadFault )); } else if(event.result.data.attributes.Loc_name == "BuildingCom.EBuildingAll" || event.result.data.attributes.Loc_name == "BuildingCom.EBuildingArea" || event.result.data.attributes.Loc_name == "BuildingCom.EBuildingNumber") { queryBuildingURL.where = "OBJECTID="+ event.result.data.attributes.Ref_ID; queryTaskBuildingURL.execute(queryBuildingURL, new AsyncResponder( onBuildingURLResults, onURLLoadFault )); } else if(event.result.data.attributes.Loc_name == "StreetCom.EStreetAll" || event.result.data.attributes.Loc_name == "StreetCom.EStreetName") { queryStreetURL.where = "OBJECTID="+ event.result.data.attributes.Ref_ID; queryTaskStreetURL.execute(queryStreetURL, new AsyncResponder( onStreetURLResults, onURLLoadFault )); } geoCoderID.clearButton.addEventListener(MouseEvent.CLICK,clearGeocoderGraphic); myMap.scale = 5000; var geocoderGraphic:Graphic = new Graphic(); geocoderGraphic.geometry = event.result.geometry; geocoderGraphic.symbol = geocoderResultSymbol; geocoderGraphic.toolTip = event.result.label.toString(); geocoderGraphic.id = "graphic"; myMap.defaultGraphicsLayer.add(geocoderGraphic); }
private function geocoderSearchAutoCompleteEventHandler(event:GeocoderEvent):void { //check to make sure there are results if (event.results.length > 0) { //clear the graphics layer before add more graphicsLayer.clear(); for(var i:int = 0; i < event.results.length; i++) { var geocoderResultsGraphic:Graphic = new Graphic(); geocoderResultsGraphic.id = "graphicResults"; geocoderResultsGraphic.geometry = event.results.geometry; geocoderResultsGraphic.toolTip = event.results.label.toString(); geocoderResultsGraphic.symbol = mySymbol; //don't use default graphicsLayer.add(geocoderResultsGraphic); } } }