addresss / intersection locator service for v2.1

708
6
Jump to solution
08-15-2012 11:23 AM
deleted-user-ugCMpXci8bn5
New Contributor III
Hello again, sorry i know I have been posting a lot lately.

I am hoping to find a locator service that will locate by address or intersection, and that will work with version 2.1 of the JS API.

I tried this locator given in the examples, which works well with 3.1, but it doesn't seem to work with 2.1 :
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/locator_addres...



Thanks, Jason
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
The method signature for addressToLocations was slightly different at version 2.1. There wasn't an options object so you just pass the address in as the first argument. Here's an example that shows this.

        var address = {"SingleLine":dojo.byId("address").value};         locator.outSpatialReference= map.spatialReference;          locator.addressToLocations(address);


You can access the 2.1 API reference by downloading the sdk for v2.1 from this page:

http://www.esri.com/apps/products/download/index.cfm

View solution in original post

0 Kudos
6 Replies
KellyHutchins
Esri Frequent Contributor
The method signature for addressToLocations was slightly different at version 2.1. There wasn't an options object so you just pass the address in as the first argument. Here's an example that shows this.

        var address = {"SingleLine":dojo.byId("address").value};         locator.outSpatialReference= map.spatialReference;          locator.addressToLocations(address);


You can access the 2.1 API reference by downloading the sdk for v2.1 from this page:

http://www.esri.com/apps/products/download/index.cfm
0 Kudos
deleted-user-ugCMpXci8bn5
New Contributor III
Thanks for the reply, but that didn't work for me...I think I am doing what you said?

Here is my locator function:
    function locate()
    {
         map.graphics.clear();
        var address = { "SingleLine": dojo.byId("address").value };
        locator.outSpatialReference = map.spatialReference;
        locator.addressToLocations(address);
    }

In the 'showResults' function I have an alert,
alert("length = " + candidates.length);

which outputs '0' ...
This code I am using is pretty much identical to the code in the ArcGIS link above.

Am I missing something? Thanks again, jason
0 Kudos
KellyHutchins
Esri Frequent Contributor
Jason,

Here's a working version of the sample, using 2.1:

http://jsfiddle.net/ZyjyC/

Can you test out the address you are trying and see if it works there? If not can you send me the address?
0 Kudos
deleted-user-ugCMpXci8bn5
New Contributor III
No you are right, I tried this in Aptana and it works.

The code I am writing is in an MVC 3 framework, which I now assume is the problem, althoughI am not sure what to do about it.

Thanks for your help, I'll check this as answered although I still have the problem! // Jason
0 Kudos
deleted-user-ugCMpXci8bn5
New Contributor III
IF you have any ideas why this works using Aptana as a normal html/css/js project, but not in MVC 3 using VS2010 with nearly identical code, I would love to hear it! // Jason
0 Kudos
MichaelVolz
Esteemed Contributor
Kelly:

I took your fiddle and modified it to use my tiled mapservice as well as geocode service but I return no results.

In the section below:

function locate() {
        map.graphics.clear();
        var address = {"SingleLine":dojo.byId("address").value};
        locator.outSpatialReference= map.spatialReference;
        var options = {
          address:address,
          outFields:["Loc_name"]
        }
        locator.addressToLocations(address);

Can you tell me what dojo.byId("address") - the address corresponds to in the parameters of the geocode service?

Does there need to be a field called Loc_name available from the geocode service?

Any help deciphering the locator code is greatly appreciated.
0 Kudos