JS: Measuring distances and areas - Not working locally

864
6
07-18-2011 07:17 AM
ShaningYu
Frequent Contributor
The script, provided by ESRI at http://www.arcgis.com/home/item.html?id=72a44473515a4c3da8289c66a1769aba, is a wonderful one.
I loaded the script and tried to run at my local unit. The drawing looks fine. However, unlike the demo there that the results display on the right panel, no result displays in my operation. I checked the function getAreaAndLength(geometry) { }. I suspected that it could be caused by the variables wmresults, utmresults and spresults, which are defined specifically. I wish the author can explain this Q, and provide the proper answer. Thanks.
0 Kudos
6 Replies
KellyHutchins
Esri Frequent Contributor
The sample you refer to uses a proxy page - you will need to setup one locally then modify the following line in the code to point to your proxy page:


esriConfig.defaults.io.proxyUrl = "proxy.ashx";


Instructions for setting up a proxy page can be found here:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm
0 Kudos
ShaningYu
Frequent Contributor
Kelly:
Thanks for your response.  I followed the procedure/approach you recommended, 

a) Download proxypage_java.zip.
b) Unzip it and then save the file into \Myserver\default\deploy\ROOT.war\ folder
c) Open the configuration proxy page (proxy.jsp) in notepad
d) Add "http://pccs000103ws:8080/CLM_GIS/", as the needed for the "<url>,<token>" .
e) Save the JSP.
f)           Copy and paste the JS_Draw_and_Measure.htm into the server's folder.  In this folder, there is another proxy.asp, the string in d) is also added.
g)          Use IE to open the page: http://pccs000103ws:8080/CLM_GIS/JS_Draw_and_Measure.htm.  The page displays and draw correctly.  However, the results are still not returned.
In my application, I can open the htm through http://pccs000103ws:8080/CLM_GIS/JS_Draw_and_Measure.htm.  Since this htm is in the same folder as the proxy.asp (see described in f)), I referred to http://geochalkboard.wordpress.com/2010/12/13/using-a-proxy-page-with-the-arcgis-server-api-for-java..., and tried to access to the proxy.asp thought browser (e.g.
http://pccs000103ws:8080/CLM_GIS/proxy.jsp), but the page dies not display.
I guess that the address for proxy file is incorrect.  How to fix it?  Thanks.
Shaning
0 Kudos
KellyHutchins
Esri Frequent Contributor
Try running the local version of your application in either Firefox with Firebug enabled or Chrome with Chrome Developer Tools open. View the NET (firebug) or Network(Chrome Developer Tools) portion and run the application to see if the requests to the geometry service project and lengths operations complete successfully.
0 Kudos
KellyHutchins
Esri Frequent Contributor
You may also want to check out the Measurement Widget. This widget was released at version 2.3 of the ArcGIS API for JavaScript and allows you to measure area and lengths. Here's a link to a sample showing how to use the widget:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_measurement.html
0 Kudos
ShaningYu
Frequent Contributor
Kelly:
Thanks for your 2 responses.  I installed and run FireBug.  I run this script again.  Sometimes, I can get the results display on the right panel, sometimes display only the Web Mercator's result, but in most of the time (> 80%), no results display.  I viewed the code (Line 69-109), I guess it could be server- or serivice-related.  The catched images are in next post.
Shaning
0 Kudos
ShaningYu
Frequent Contributor
This is the continuation of my last post with the addition of the 2 images that show the Results.
0 Kudos