ArcGIS Server Javascript API Gotcha: Identify

I ran into an odd problem after I installed SP1 (actually a few odd problems) with a site using the ArcGIS Server javascript API.  Basically, the identify task broke in IE only.  All was well in Firefox, so I was stumped, as I didn’t receive any error messages.  So, I cranked open Fidder which revealed that the HTTP request was never happening.  Strange, I thought, so I copied the HTTP request that was working in Firefox from the Firebug Net tab and pasted it into the IE address bar, yet it wouldn’t let me paste the whole URL.  So, the URL was too long…but why?  As it turns out the IdentifyParameters use a geometry, and that geometry has a spatialReference, which comes from the map.  The spatialReference we use is WKID 2913, which is one of the Oregon State Plane projected systems.   When the API sets this value on the javascript map object, it uses the Well-Known Text (WKT) version, which is a REALLY long string.  So, I overwrite the spatialReference on the geometry before executing the identify task with a light object that just has the WKID.  Like so:

function doIdentify(evt) {
    taskParameters.mapExtent =;
    taskParameters.geometry = evt.mapPoint;
    // have to do this in order to make this work in IE.
    // otherwise the AGS jsapi will post the WKT which makes the URL too long.
    taskParameters.geometry.spatialReference = { wkid: 2913, toJson: function() { return '{"wkid":"2913"}'; } };

    var task = new esri.tasks.IdentifyTask(serv.URL);
    taskParameters.height =;
    taskParameters.width =;
    task.execute(this.taskParameters, _identifyResults);


Once the URL wasn’t too long, identify started working in IE again.

Anyone else having any issues after installing AGS 9.3 SP1?

Reblog this post [with Zemanta]

About Ruprict

I am a nerd that is a Nerd Wannabe. I have more kids than should be allowed by law, a lovely wife, and a different sense of humor than most. I work in the field of GIS, where I am still trying to find myself on the map. View all posts by Ruprict

9 responses to “ArcGIS Server Javascript API Gotcha: Identify

  • Dave Bouwman

    While I like the general RESTness of the ESRI REST API, I think they should facilitate POSTing for some of these query methods – sacrifice some RESTness for some pragmatism. The fact that these querystrings get long is a know issue, and part of the reason they have a proxy.ashx that you can POST to, and it will then re-format it and make the request. More info here

  • ruprict

    I have been avoiding the proxy page, b/c I am lazy. Guess I’ll get it going tomorrow. I still find it odd that this little bug didn’t popup until after I installed SP1.

    Thanks for the link!

  • vish

    Hi Glenn,

    I haven’t installed SP1 yet. It is on my list of things to do this week. Anyway, I am having trouble understanding your problem though. From what you have written, it looks like you are saying that the JS API has changed. Has ESRI released v1.2 of the JS API and have it available on their servers? If so, please do let me know. If not, your problem is something else since SP1 should not have anything to do with JS API. Let me know what you find out.

    Thank You,

  • ruprict

    Hey Vish,

    Fair enough. The change would have to be with the REST API, presuming there is a change. My best guess, and I may never confirm this, is that the REST API is returning WKT values for the map spatial Ref once the first service is added to the map. Then, that spatial Ref is being pushed on to the event.mapPoint used by the identify task, which is then finally pushed into the REST URL.

    Might be a long way home….can you confirm if the identify geometry in the pre SP1 REST+jsapi land is using the WKT before you upgrade?

    Thanks…and I am might have to use your slider….

  • viswaug

    Hi Glenn,

    The identify geometry in the pre SPI REST + jsapi uses the WKID for the spatial reference and not the WKT.


  • Ravi

    Projection ID 2913 represents NAD_1983_StatePlane_Oregon_North_FIPS_3601_Intl_Foot.

    Can you check if the coordinate system defined for the Map uses this projection? If the name of the coordinate system used is different, it is likely being treated as a custom projection and hence WKT is returned for the spatial reference of the service. To set the coordinate system of the dataframe to 2913:

    1. open the map document in ArcMap
    2. right click on the dataframe “Portland” and select properties
    3. click on the “Coordinate System” tab
    4. In the box to select a coordinate system, click Predefined -> Projected Coordinate Systems -> State Plane -> NAD 83 HARN (Feet,Intl,Us) -> NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601_Feet_Intl and click OK.
    5. Save the map to a different name so that you preserve the old one.
    6. Try serving this map (and make sure to clear the REST cache if using an existing service).


  • Ravi

    Minor correction–

    2913 represents: “NAD_1983_Harn_StatePlane_Oregon_North_FIPS_3601_Intl_Foot.

  • ruprict


    So, that seems to have fixed it. The coord sys was already set to 2913 on that dataframe, so I just re-did that and it seems to have cleared it out. The geometry on the map click event is now using WKID.

    Any idea as to why? Or, is the only answer that I am crazy?


  • Ravi

    The name of the projection along with all the projection parameters is taken into consideration to determine if the projection is custom or standard. My guess is that the name of the projection defined in your map was different from “NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601_Feet_Intl”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: