Select to view content in your preferred language

Measuring Tool - Changing the Default Units from Meters to Feet?

10088
15
10-15-2012 11:21 AM
IanPeebles
Frequent Contributor
My data is in state plane coordinates. . the units are in feet, but the measuring tool comes in a meters by default.

Has anyone changed the default measuring units from meters to feet?  I want to keep the lat and long coordinate, but want to expand the number of decimal places from 2 to 6.

Anyone have any suggestions?
0 Kudos
15 Replies
IanPeebles
Frequent Contributor
Does anyone have any suggestions for this issue?  All I need is:

1. Changing the default units from meters to feet by default.  Right now a end user has to go in and change the units each time they need to make a measurement. . even when the measuring tool references the organizations geometry service.

2. Also the coordinates I need from 2 decimal places to 6. Example -97.123456 and 35.123456 rather than -97.12 and 35.12.

The out of the box sample for version 3.0 does not provide me the capability to make these changes.  I was hoping this would be much more configurable.
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Ian,

For the Meters/Feet issue, the variable you need is set in the MeasureViewModel.cs file. Look near the top and you'll see the Linear and Areal default units (I've attached a screenshot). Change the LinearUnit = LengthUnits.UnitsFeet instead of LengthUnits.UnitMeters. Then compile the solution, remove the existing Measure tool from the Application Builder, and upload the newly compiled Xap file. You may need to refresh your Browser.  

For the coordinates issue, you'll need to edit the MeasureView.xaml file. Find the following bits and change the StringFormat attribute. For example, where it says {0:n2\}, change the "n2" to "n5" or the desired number of digits after the decimal.

**Note - if you already have a version of the Measure Tool from ArcGIS Online, we've made a small update to it today, so please re-download it.

  <!-- Latitude value -->
            <TextBlock
                Margin="5,5,0,0"
                Text="{Binding Path=Latitude, StringFormat=\{0:n2\}}"
                Visibility="{Binding Latitude,
                    Converter={StaticResource NotNullToVisibilityConverter}}"
                Grid.Row="1"
                Grid.Column="1"/>

<!-- Longitude value -->
            <TextBlock
                Margin="5,5,0,0"
                Text="{Binding Longitude, StringFormat=\{0:n2\}}"                               
                Visibility="{Binding Longitude,
                    Converter={StaticResource NotNullToVisibilityConverter}}"
                Grid.Row="2"
                Grid.Column="1"/>


Hope that helps,
Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
IanPeebles
Frequent Contributor
Hi Ian,

For the Meters/Feet issue, the variable you need is set in the MeasureViewModel.cs file. Look near the top and you'll see the Linear and Areal default units (I've attached a screenshot). Change the LinearUnit = LengthUnits.UnitsFeet instead of LengthUnits.UnitMeters. Then compile the solution, remove the existing Measure tool from the Application Builder, and upload the newly compiled Xap file. You may need to refresh your Browser.  

For the coordinates issue, you'll need to edit the MeasureView.xaml file. Find the following bits and change the StringFormat attribute. For example, where it says {0:n2\}, change the "n2" to "n5" or the desired number of digits after the decimal.

**Note - if you already have a version of the Measure Tool from ArcGIS Online, we've made a small update to it today, so please re-download it.

  <!-- Latitude value -->
            <TextBlock
                Margin="5,5,0,0"
                Text="{Binding Path=Latitude, StringFormat=\{0:n2\}}"
                Visibility="{Binding Latitude,
                    Converter={StaticResource NotNullToVisibilityConverter}}"
                Grid.Row="1"
                Grid.Column="1"/>

<!-- Longitude value -->
            <TextBlock
                Margin="5,5,0,0"
                Text="{Binding Longitude, StringFormat=\{0:n2\}}"                               
                Visibility="{Binding Longitude,
                    Converter={StaticResource NotNullToVisibilityConverter}}"
                Grid.Row="2"
                Grid.Column="1"/>


Hope that helps,
Katy


Thanks Katy.  The problem I am having is that I cannot seem to modify the add-in that comes with the latest viewer.  Is there a way I can work with the add in alone?  All I see is the .xap file.
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Ian,

You'll need to download the Measure Tool sample from ArcGIS Online. After you unzip the file, you'll see that it includes the full source code for the Measure tool, exactly as it is included in the Application. You'll need to make the edits as described in my earlier post, and then rebuild the solution. The resulting .xap file is what you will then load into the ArcGIS Viewer for Silverlight in the same manner as you would other add-ins.

Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
IanPeebles
Frequent Contributor
Hi Ian,

You'll need to download the Measure Tool sample from ArcGIS Online. After you unzip the file, you'll see that it includes the full source code for the Measure tool, exactly as it is included in the Application. You'll need to make the edits as described in my earlier post, and then rebuild the solution. The resulting .xap file is what you will then load into the ArcGIS Viewer for Silverlight in the same manner as you would other add-ins.

Katy


Katy,

Thanks for all of your input.  I downloaded the sample. . opened the solution file and made the changes you suggested.  The Add-ins part of the project did not open. I then did a debug and a rebuild, but the problem is that the .xap file located outside of the MeasureTool.Addins and MeasureTool.Web did not update to today's date.  I even tried to open both folders in Visual studio and did a rebuild, but same result.  Any ideas?  See the screenshot below.
0 Kudos
RichZwaap
Frequent Contributor
Hi Ian:

The xap in the root of the zip file will not be updated when you compile the source.  Rather, you'll need to copy the add-in's xap file from the output location under the Source Code folder (i.e. Source Code\MeasureTool\MeasureTool.AddIns\Bin).  The xap should be contained in a Release or Debug folder in that location, depending on whether you have compiled the add-in using the Debug or Release configuration.

However, if the MeasureTool.AddIns project is failing to load when you open the project in Visual Studio, then you probably lack some pre-requisites for developing Viewer add-ins.  You'll need to install the Microsoft Silverlight 5 Tools for Visual Studio 2010 and the latest Silverlight Toolkit.
0 Kudos
IanPeebles
Frequent Contributor
Hi Ian:

The xap in the root of the zip file will not be updated when you compile the source.  Rather, you'll need to copy the add-in's xap file from the output location under the Source Code folder (i.e. Source Code\MeasureTool\MeasureTool.AddIns\Bin).  The xap should be contained in a Release or Debug folder in that location, depending on whether you have compiled the add-in using the Debug or Release configuration.

However, if the MeasureTool.AddIns project is failing to load when you open the project in Visual Studio, then you probably lack some pre-requisites for developing Viewer add-ins.  You'll need to install the Microsoft Silverlight 5 Tools for Visual Studio 2010 and the latest Silverlight Toolkit.


Rich,

I did do the upgrades you suggested.  Below are screenshots on where I am at.  I opened the AddIn in Visual Studio, then did a rebuild and save.  Still not getting the .XAP file updated though it was moved to the debug folder.  The only changes I have made were to the MeasureViewModel.cs (changing the units) and the MeasureView.xaml (expanding digits past the decimal) files.  Hopefully, I am getting closer.  To do appreciate the input.
0 Kudos
RichZwaap
Frequent Contributor
If the xap file is present in the Debug folder, then it is compiling - that xap file contains your changes.  Now that you have it, you need to replace the version in the Application Builder with the new version.  To do this:


  1. Open the Application Builder

  2. Click the Settings link (upper right)

  3. Click the Add-Ins tab

  4. Next to MeasureTool.AddIns, click the delete button.  Confirm the deletion when prompted.

  5. Clear your browser cache.  If you are using Internet Explorer, the most reliable way is to open a command prompt and input the command "rundll32.exe inetcpl.cpl,ClearMyTracksByProcess 8"

  6. Refresh the browser page

  7. Navigate to Settings --> Add-Ins again

  8. Click the "Upload Add-Ins" button

  9. Browse to your compiled version of the MeasureTool.Addins.xap file.  Make sure you select the one under the Debug folder.

  10. Create a new app and add the Measure Tool to it.  When you try it out, you should see your changes.


That should do it for you.
0 Kudos
IanPeebles
Frequent Contributor
If the xap file is present in the Debug folder, then it is compiling - that xap file contains your changes.  Now that you have it, you need to replace the version in the Application Builder with the new version.  To do this:


  1. Open the Application Builder

  2. Click the Settings link (upper right)

  3. Click the Add-Ins tab

  4. Next to MeasureTool.AddIns, click the delete button.  Confirm the deletion when prompted.

  5. Clear your browser cache.  If you are using Internet Explorer, the most reliable way is to open a command prompt and input the command "rundll32.exe inetcpl.cpl,ClearMyTracksByProcess 8"

  6. Refresh the browser page

  7. Navigate to Settings --> Add-Ins again

  8. Click the "Upload Add-Ins" button

  9. Browse to your compiled version of the MeasureTool.Addins.xap file.  Make sure you select the one under the Debug folder.

  10. Create a new app and add the Measure Tool to it.  When you try it out, you should see your changes.


That should do it for you.


Rich,

I think everything is place and I removed the tool and cleared the cache, then re-added the add-in, but getting the same results.  The date of the .XAP file in the Debug folder is 10/12/2012 even after the rebuild and save. If the .XAP rebuilt shouldn't it be 10/30/2012?  In terms of my environment I have the ArcGIS Silverlight API 3.0, the ArcGIS Extensibility SDK 3.0, The ArcGIS Silverlight Viewer 3.0, Microsoft Silverlight 5 SDK and Microsoft Silverlight Tools for Visual Studio 2010.  I initially modified the two files I mentioned above using Notepad++ since they were simple changes.
0 Kudos