Select to view content in your preferred language

Searchbox in 3.1

2705
20
12-18-2012 03:52 AM
LemvigKommune
Deactivated User
Hi, I'm trying to use the FV 3.1, and with that using a local geocode-service.
When I use it in the header, it's like it's dropping off the earth, but if I use the same geocode-service in the locator-widget, it works like a charm.
I've added the locator that I've used as a geocode-package, hope somebody can help.
Tags (2)
0 Kudos
20 Replies
HeatherGonzago
Esri Contributor
Hi everyone,

We got the same issue that you described above and after a lot of testing it appears the issue is related to how the geocoding locator service is set up.

The application expects 'optional' result extent coordinates (Geographic), which will fail if a custom Geocoder does not have set since it will erroneously create an extent at 0,0.

When creating a locator, the optional result extent coordinates are not automatically set.
More on this is written in the help at http://resources.arcgis.com/en/help/main/10.1/index.html#//00250000004n000000, under Return display extent output fields.

The easiest way I found was to go into your locator's (not the service) properties > and there is an outputs option > click on "return display extent output fields" set to yes, by default it's no. > rebuild the locator > republish the service.

[ATTACH=CONFIG]20604[/ATTACH]


You should not get the result off of Africa anymore. We are updating the fix but for now, please use this as a workaround.
0 Kudos
ChrisNorth
Esri Contributor
Hi Heather,

Thanks for continuing to look into this.  Your solution above does not seem to work for me.  I had already tried that, but tried it again, building a brand new geocoder, then setting the option to "yes", rebuilding and then publishing a new service.  I'm still going to the Atlantic Ocean.  It might be due to the fact that by source data does not have the XMin, YMin, XMax, YMax data in it (I'm using street data and a dual range style).

I'll keep plugging away.  The stand-alone locator widget does work fine, just not the search box in the header control widget.

Chris
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
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);
            }
0 Kudos
Juan_CarlosFranco
Esri Contributor
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.
0 Kudos
Juan_CarlosFranco
Esri Contributor
Robert,

Unfortunately, your suggested fix won't address the issue since an erroneous result extent would still be created and used.

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);
            }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
JC,

   Thanks. I thought that the getGeographicResultExtent would return null and thus not make it to the WebMercatorUtil.geographicToWebMercator
0 Kudos
JoshWhite
Honored Contributor
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.


My issue is definitely 2b. Heather's workaround didn't work for me either.
Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
ChrisNorth
Esri Contributor
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.


Hi All,

Just wanted to touch base and see if there is a new build or fix for this issue.  It's holding back a project from moving to the 3.1 viewer as we will be using our own geocoding service.

Thanks,
Chris
0 Kudos
JoshWhite
Honored Contributor
Chris,
you can still use the Locator widget in 3.1 with your own  geocoder.  I use it without any issue, but, naturally still cannot use the search box in the Header.
Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
DominiqueBerger
Emerging Contributor
Hi guys

I too was just wondering if there had been a fix for this as yet?

Thanks very much

Dominique
0 Kudos