Direction widget with JS API 3.14 not honoring “directionLengthUnits” parameter

3096
4
08-19-2015 12:38 AM
sumitzarkar
Occasional Contributor

While using direction widget with JS API 3.14, we have observed that, The direction widget(“esri/dijit/direction”)  is not honoring “directionLengthUnits” property and always displays route length unit in “miles”.

However in JS API 3.13,  It honors the configured value for “directionLengthUnits” property to display the route length unit.

Attached is the code samples with the direction widget implementation using JS API 3.13 and 3.14.

 var directions = new Directions({
          map: map,
          directionsLengthUnits: esriUnits.METERS
        },"dir");
        directions.startup();

Seems to be an bug with 3.14 API, please suggest.

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Sumit,

  The supported units are only miles or kilometers.

Length units. Supported units are miles and kilometers. Use the constant units or their string equivalents ("esriKilometers" | "esriMiles").

Known values: esriUnits.KILOMETERS | esriUnits.MILES

Check out the documentation page that states the above.

sumitzarkar
Occasional Contributor

Thanks Robert Scheitlin, GISP

we missed that, however we tried using esriUnits.KILOMETERS but still the widget is showing result only in miles.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Directions Widget</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
    <style>
      html, body, #map {
        height:100%;
        width:100%;
        margin:0;
        padding:0;
      }
      body {
        background-color:#FFF;
        overflow:hidden;
        font-family:"Trebuchet MS";
      }
    </style>


    <script src="http://js.arcgis.com/3.14/"></script>
    <script>
      require([
        "esri/urlUtils", "esri/map", "esri/dijit/Directions", "esri/units",
        "dojo/parser", 
        "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
      ], function(
        urlUtils, Map, Directions,units,
        parser
      ) {
        parser.parse();
        //all requests to route.arcgis.com will proxy to the proxyUrl defined in this object.
        urlUtils.addProxyRule({
          urlPrefix: "route.arcgis.com",  
          proxyUrl: "/sproxy/"
        });
        urlUtils.addProxyRule({
          urlPrefix: "traffic.arcgis.com",  
          proxyUrl: "/sproxy/"
        });


        var map = new Map("map", {
          basemap: "streets",
          center:[-98.56,39.82],
          zoom: 4
        });


        //travelModesServiceUrl option points to logistics service hosted from ArcGIS Online
        //by indicating this URL, a login prompt should not display
        var directions = new Directions({
          map: map,
          directionsLengthUnits: units.KILOMETERS,
          travelModesServiceUrl: "http://utility.arcgis.com/usrsvcs/servers/cdc3efd03ddd4721b99adce219629489/rest/services/World/Utili..."
        },"dir");
        directions.startup();
      });
    </script>
  </head>
  <body class="claro">
    <div data-dojo-type="dijit/layout/BorderContainer" 
         data-dojo-props="design:'headline', gutters:false" 
         style="width:100%;height:100%;">
      <div data-dojo-type="dijit/layout/ContentPane" 
           data-dojo-props="region:'right'" 
           style="width:250px;">
        
        <div id="dir"></div>
      </div>
      <div id="map" 
           data-dojo-type="dijit/layout/ContentPane" 
           data-dojo-props="region:'center'">
      </div>
    </div>
  </body>
</html>
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sumit,

   You are correct I am finding the same the directionsLengthUnits in the constructor is being ignored in 3.14. You will need to submit this bug to esri tech support.

sumitzarkar
Occasional Contributor

Kelly Hutchins

Can you please confirm if this is a bug or we are missing something.

0 Kudos