I am specifying a value for input textbox of the geocoder. It is a field (geoPlace) that is calculated. It fills in the textbox just fine. I would like for it to then automatically zoom to that place at startup. Is there a way to do this? It seems like I should use geocoder.find() but I haven't been successful.
geocoder = new Geocoder({
map: map,
value: geoPlace
}, "search");
geocoder.startup();
Solved! Go to Solution.
Hi Laura,
Check out the Geocode an address | ArcGIS API for JavaScript sample. This sample geocodes an address then zooms to the location.
You should be able to insert your geoPlace variable into the locate function - something like:
function locate() { map.graphics.clear(); var address = { "SingleLine": geoPlace }; locator.outSpatialReference = map.spatialReference; var options = { address: address, outFields: ["Loc_name"] } locator.addressToLocations(options); }
Hope this helps,
Owen
Hi Laura,
Check out the Geocode an address | ArcGIS API for JavaScript sample. This sample geocodes an address then zooms to the location.
You should be able to insert your geoPlace variable into the locate function - something like:
function locate() { map.graphics.clear(); var address = { "SingleLine": geoPlace }; locator.outSpatialReference = map.spatialReference; var options = { address: address, outFields: ["Loc_name"] } locator.addressToLocations(options); }
Hope this helps,
Owen
Thank you! This is exactly what I needed.