I want to control the map scale on the Search widget, which I think zooms in too close for my purposes. I have turned off autoNavigate, but it still zooms in the same as it always has. Do I have the parameter in the wrong spot?
//Search widget, used for geocoding app.searchTool = new Search ({ map:app.map, minCharacters: 8, countryCode: "US", searchExtent:app.startExtent }, dom.byId('geocoder')); var sources = []; sources.push({ locator: new Locator("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"), singleLineFieldName: "SingleLine", outFields: ["Addr_type"], name: "World Geocode Service", localSearchOptions: { minScale: 300000, distance: 50000 }, placeholder: "Enter Address", highlightSymbol: new PictureMarkerSymbol(app.geoSymbol).setOffset(9, 18), showInfoWindowOnSelect:false, enableInfoWindow:true, autoNavigate:false }); app.searchTool.set("sources", sources); app.searchTool.startup(); app.searchTool.on("select-result", function (evt){ var addr = evt.result.name; var containsCounty = addr.indexOf(' County,'); if (containsCounty > 0){ app.map.centerAndZoom(evt.result.feature.geometry, 10); }else { app.map.centerAndZoom(evt.result.feature.geometry, 14); } });
Solved! Go to Solution.
You need to specify autoNavigate on the search widget not the source.
var search = new Search({ map: map, autoNavigate: false }, "search");
You need to specify autoNavigate on the search widget not the source.
var search = new Search({ map: map, autoNavigate: false }, "search");
I had it there at one point. I guess something I read made me think it was wrong, so I moved it! In the help it's listed again under the syntax for the sources. I guess that gave me the idea that it didn't matter. The help is confusing. Some parameters are listed for both the Search constructor as well as the sources definition.