Using new measurement widget

7790
25
07-14-2014 11:43 AM
StevenGraf1
Occasional Contributor III

I see they added the ability to determine the xy locations for other coordinate systems, such as UTM, USNG, etc.  When I add the param


advancedLocationUnits:true

var measurement = new Measurement({
    map: map,
     advancedLocationUnits:true
    defaultAreaUnit: Units.SQUARE_MILES,
    defaultLengthUnit: Units.KILOMETERS
  }, dom.byId('measurement'));

it adds the new units to the drop down but when I click on the map it doesn't return any thing.  I was just playing in the sandbox for the measurement samples.  Is there something else you need to add to return those projected coordinates?

0 Kudos
25 Replies
AdrianMarsden
Occasional Contributor III

Missed this option when it was added - just tried it.  No difference.  Just get the two Degrees, and DMS.

0 Kudos
StevenGraf1
Occasional Contributor III

Did you change your css and script links to the new version of the js api?  This came out with the 3.10 release.

0 Kudos
StevenGraf1
Occasional Contributor III

You also have to use:

esri.config.defaults.geometryService = new esri.tasks.GeometryService("yourgeometryservice");

I get the added location units but when I try one, it returns Geometry Service Error.

0 Kudos
AdrianMarsden
Occasional Contributor III

For my issue,I have both of those - the latest code and default geometry service set to one of mine.

0 Kudos
RamonCampos
New Contributor II

On line #3 of your example code above, you are missing a comma (,) after advancedLocationUnits:true . In the Sandbox, when I added that comma, and updated the Units reference to the fully qualified esri.Units.SQUARE_MILES ...etc., it worked for me.

0 Kudos
StevenGraf1
Occasional Contributor III

I had the comma in there.  For some reason I didn't get it copied over.  I still get the Geometry Service Error.

Not sure what's going on.

Here's a fiddle showing the ESRI measurement sample with the advancedLocationUnits.  It doesn't return anything.  My service will say Geometry Service Error where the lat/long is supposed to be.

Edit fiddle - JSFiddle

0 Kudos
RamonCampos
New Contributor II

Using your fiddle I updated the code to use my own geometry service and I get no errors. The lat/long coordinates display as expected. My guess would then be that the error is going to be with how your geometry service is configured. Is it publicly accessible? Or is it on an intranet that is not public facing? Does it support "Areas and Lengths", "Distance", and "Lengths" operations? Just throwing out some ideas. I am not sure from this point what else it might be.

Best of luck.

0 Kudos
StevenGraf1
Occasional Contributor III

My lat/long display in DD and DMS.

It's when I switch to the new advanced units it doesn't work properly.  It's public and supports the following (version 10.2.2)

Areas and Lengths   Auto Complete   Buffer   Convex Hull   Cut   Densify   Difference   Distance   Generalize   Intersect   Label Points   Lengths   Offset   Project   Relation  Reshape   Simplify   Trim Extend   Union

0 Kudos
RamonCampos
New Contributor II

My apologies. I left the selection for the units on "Degrees". I now see the same error as you when I select one of the advanced location units.

I turned on Chrome Developer Tools and in the console log, when clicking the map after selecting any of the advanced location units, I see the error message

dojo.io.script error

Error {code: 400, message: "Unable to complete operation.", details: Array[1], log: undefined, httpCode: 400…} (init.js:512)

and also

Uncaught TypeError: Cannot read property 'domNode' of undefined (Measurement.js:43)

Both of these are in ESRI's js files. So unless someone has another idea, I think it may be a bug in the API.

0 Kudos