James,
I don't have any code available off top hand - I know that's the service that is called by default. Well, "find candidates" is, at least. You can set sources:
Search | API Reference | ArcGIS API for JavaScript
I think you should be able to set it to the Esri default world geocoder as a source yourself, and then set the "searchExtent" property on the source object, kinda like so:
var extent = new esri.geometry.Extent({ "xmin":-81.465144,"ymin":26.949436,"xmax":-83.465144,"ymax":28.949436, "spatialReference":{"wkid":4326} }); var sources = [ { locator: , singleLineFieldName: "SingleLine", name: "Custom Geocoding Service", localSearchOptions: { minScale: 300000, distance: 50000 }, placeholder: "Search Geocoder", maxResults: 3, maxSuggestions: 6, enableSuggestions: false, minCharacters: 0 }, { featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"), searchFields: ["Name", "Party"], suggestionTemplate: "${Name}, Party: ${Party}", exactMatch: false, outFields: ["*"], name: "Senators", labelSymbol: textSymbol, placeholder: "Senator name", maxResults: 6, maxSuggestions: 6, enableSuggestions: true, minCharacters: 0 }, { featureLayer: new FeatureLayer(),{ outFields: ["*"] }); placeholder: "esri", name: "A FeatureLayer", prefix: "", suffix: "", maxResults: 1, maxSuggestions: 6, searchExtent: extent, exactMatch: false, searchFields: [], // defaults to FeatureLayer.displayField displayField: "", // defaults to FeatureLayer.displayField labelSymbol: new TextSymbol(), minCharacters: 0 } ];
We know it's supported, at least in theory, by the service link I posted. I'll have to look into creating a sample app when I get a free moment.
4th St & D is an intersection
james a, you'll need to be more specific about what you are trying to do before anyone will be able to help you.
Jeff,
That's is what I need. The user can just type in two street names like your example without specific city then able to zoom to location after you select one of the results.
Thank you.
By default (using Esri's World Geocoding service) it looks like you are required to enter the city along with the intersection.
As far as I know, the only way around this is to host your own geocoding service, and thus you would need create a custom address locator which would only require the user to enter streets.
I actually think it may be possible:
This returns:
{ "spatialReference": { "wkid": 4326, "latestWkid": 4326 }, "locations": [ { "name": "E Madison St & N Marion St, Tampa, Florida, 33602", "extent": { "xmin": -82.456560999999994, "ymin": 27.949013000000001, "xmax": -82.456560999999994, "ymax": 27.949013000000001 }, "feature": { "geometry": { "x": -82.456559754528257, "y": 27.949013008444638 }, "attributes": { "Score": 84.469999999999999, "Addr_Type": "StreetInt" } } } ] }
I provided a bounding box and location origin point - seems to return results for something like "Madison and Marion" without adding city or state.
Would you mind show me your javascript code? So you basically have to create a map extent to define the boundary?
Thank you.
James,
I don't have any code available off top hand - I know that's the service that is called by default. Well, "find candidates" is, at least. You can set sources:
Search | API Reference | ArcGIS API for JavaScript
I think you should be able to set it to the Esri default world geocoder as a source yourself, and then set the "searchExtent" property on the source object, kinda like so:
var extent = new esri.geometry.Extent({ "xmin":-81.465144,"ymin":26.949436,"xmax":-83.465144,"ymax":28.949436, "spatialReference":{"wkid":4326} }); var sources = [ { locator: , singleLineFieldName: "SingleLine", name: "Custom Geocoding Service", localSearchOptions: { minScale: 300000, distance: 50000 }, placeholder: "Search Geocoder", maxResults: 3, maxSuggestions: 6, enableSuggestions: false, minCharacters: 0 }, { featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"), searchFields: ["Name", "Party"], suggestionTemplate: "${Name}, Party: ${Party}", exactMatch: false, outFields: ["*"], name: "Senators", labelSymbol: textSymbol, placeholder: "Senator name", maxResults: 6, maxSuggestions: 6, enableSuggestions: true, minCharacters: 0 }, { featureLayer: new FeatureLayer(),{ outFields: ["*"] }); placeholder: "esri", name: "A FeatureLayer", prefix: "", suffix: "", maxResults: 1, maxSuggestions: 6, searchExtent: extent, exactMatch: false, searchFields: [], // defaults to FeatureLayer.displayField displayField: "", // defaults to FeatureLayer.displayField labelSymbol: new TextSymbol(), minCharacters: 0 } ];
We know it's supported, at least in theory, by the service link I posted. I'll have to look into creating a sample app when I get a free moment.
Here is the example to find street intersection:
Nice!