+ Reply to Thread
Results 1 to 7 of 7

Thread: addresss / intersection locator service for v2.1

  1. #1
    Jason Fitzsimmons
    Join Date
    May 2012
    Posts
    91
    Points
    0
    Answers Provided
    1


    0

    Default addresss / intersection locator service for v2.1

    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/jav...r_address.html



    Thanks, Jason

  2. #2
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    1
    This post is marked as the answer

    Default Re: addresss / intersection locator service for v2.1

    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.

    Code:
            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

  3. #3
    Jason Fitzsimmons
    Join Date
    May 2012
    Posts
    91
    Points
    0
    Answers Provided
    1


    0

    Default Re: addresss / intersection locator service for v2.1

    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

  4. #4
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    0

    Default Re: addresss / intersection locator service for v2.1

    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?

  5. #5
    Jason Fitzsimmons
    Join Date
    May 2012
    Posts
    91
    Points
    0
    Answers Provided
    1


    0

    Default Re: addresss / intersection locator service for v2.1

    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

  6. #6
    Jason Fitzsimmons
    Join Date
    May 2012
    Posts
    91
    Points
    0
    Answers Provided
    1


    0

    Default Re: addresss / intersection locator service for v2.1

    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

  7. #7
    Michael Volz
    Join Date
    May 2010
    Posts
    1,381
    Points
    186
    Answers Provided
    23


    0

    Question Re: addresss / intersection locator service for v2.1

    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.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts