Hello everyone,Just wanted to drop by and update everyone on the status of this issue.There are two problems with the search component:1. Expecting display extent output fields (Geographic), which will fail if a custom locator does not have these set since it will erroneously create an extent with the following coordinates (0,0,0,0). See Heather's workaround for this.2a. Not projecting stored search results that might have a different spatial reference than the map. The only way to work around this is to avoid using stored search results (shown when typing) and always perform a search and selecting from the displayed search results (applies only to maps in Geographic or Web Mercator).2b. Not projecting the result extent coordinates if the map is not in Geographic or Web Mercator.I'll push the fix to our GitHub repository as soon as it's been tested and verified.Thank you for your patience and I apologize for the inconvenience.
Chris, The fix for this is pretty simple if you are using the source code. Her is the change indicated in red:file location:src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml private function showSearchResultOnMap(searchResult:Object):void { map.defaultGraphicsLayer.remove(searchResultGraphic); const infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer); const popUpInfo:PopUpInfo = new PopUpInfo(); popUpInfo.title = searchResultTitleLabel; popUpInfo.showZoomToButton = false; //hide the zoom to button as map would be zoomed-in var resultExtent:Extent; if (searchResult is FindResult) { const findResult:FindResult = searchResult as FindResult; const resultLabel:String = findResult.value; searchTerm = resultLabel; searchResultGraphic.geometry = findResult.feature.geometry; searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); popUpInfo.description = findResult.value; } else if (searchResult is AddressCandidate) { const addressCandidate:AddressCandidate = searchResult as AddressCandidate; searchTerm = addressCandidate.address as String; resultExtent = getGeographicResultExtent(addressCandidate); if (map.spatialReference.isWebMercator() && resultExtent) { resultExtent = WebMercatorUtil.geographicToWebMercator(resultExtent) as Extent; } searchResultGraphic.geometry = addressCandidate.location; searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); popUpInfo.description = addressCandidate.address as String; } else { return; } storeSearchResult(searchResult); infoWindowRenderer.properties = { popUpInfo: popUpInfo }; searchResultGraphic.infoWindowRenderer = infoWindowRenderer; if (searchResultGraphic.symbol) { map.defaultGraphicsLayer.add(searchResultGraphic); } popUpRenderer.popUpInfo = popUpInfo; popUpRenderer.graphic = 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 showSearchResultOnMap(searchResult:Object):void { map.defaultGraphicsLayer.remove(searchResultGraphic); const infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer); const popUpInfo:PopUpInfo = new PopUpInfo(); popUpInfo.title = searchResultTitleLabel; popUpInfo.showZoomToButton = false; //hide the zoom to button as map would be zoomed-in var resultExtent:Extent; if (searchResult is FindResult) { const findResult:FindResult = searchResult as FindResult; const resultLabel:String = findResult.value; searchTerm = resultLabel; searchResultGraphic.geometry = findResult.feature.geometry; searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); popUpInfo.description = findResult.value; } else if (searchResult is AddressCandidate) { const addressCandidate:AddressCandidate = searchResult as AddressCandidate; searchTerm = addressCandidate.address as String; resultExtent = getGeographicResultExtent(addressCandidate); if (map.spatialReference.isWebMercator() && resultExtent) { resultExtent = WebMercatorUtil.geographicToWebMercator(resultExtent) as Extent; } searchResultGraphic.geometry = addressCandidate.location; searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); popUpInfo.description = addressCandidate.address as String; } else { return; } storeSearchResult(searchResult); infoWindowRenderer.properties = { popUpInfo: popUpInfo }; searchResultGraphic.infoWindowRenderer = infoWindowRenderer; if (searchResultGraphic.symbol) { map.defaultGraphicsLayer.add(searchResultGraphic); } popUpRenderer.popUpInfo = popUpInfo; popUpRenderer.graphic = 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); }
I'm very curious about this as well, I've removed this temporarily to avoid any other errors. Please let us know what you find out.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.