Getting error while instantiation of CreateDriveTimeAreas

11-01-2017 04:20 AM
New Contributor

I am trying to create drive time areas for a point. When I call the routine I get the following error.

Uncaught Error: string.substitute could not find key "layername" in template
at String.replace (<anonymous>)
at Object.r.substitute (
at Object._updateAnalysisLayerUI (
at Object._buildUI (
at Object.postCreate (
at Object.create (
at Object.postscript (
at Object.advice (
at Object.c [as postscript] (

Background -

  • I have a small area FeatureLayer on ArcGIS online from which I am creating an activeFeatureLayer programmatically and is as well the active layer on the visible map.
  • I also have a mapLayer that is created as an overlay on the current active layers on the map. This layer holds information regarding the drop point on the map with/without buffer distance.

I am following the javascript jsapi 3 documentation( for this. This is what I am doing -

var activeFeatureLayer = new FeatureLayer("<auth_id>/arcgis/rest/services/<layer_id>/FeatureServer/0");

var createDriveTimeAreas = new CreateDriveTimeAreas({
inputLayer: activeFeatureLayer,
inputType: "point",
showReadyToUseLayers: false, // to disable an option to the UI that allows users to choose ready to use analysis layers from the Living Atlas Analysis Layers
portalUrl: "https://<server>"
}, "analysis-tool");

  1. The code breaks when the instantiation of the CreateDriveTimesAreas is called.
  2. I am not sure whether is pertaining to portalUrl.

Can anyone please tell me what I am doing wrong here?

Thank you.

0 Kudos
5 Replies
New Contributor III

I posted this here too:

If you add a "name" property to your input layer, you'll work around there.  In the CreateDriveTimeAreas code, "layername" is set to your  Layers from ArcGIS Online have this.  Layers created from instantiating your own FeatureLayer do not.
Basically, add: = "Some name";
Unfortunately, in my own case, I still could not get CreateDriveTimeAreas to work, but the step above did get rid of that "layername" error message for me.

0 Kudos
Esri Contributor

Hi Matt, 

We will fix this issue in coming release of JSAPI. you can use the current workaround you suggested above. 

Unfortunately, in my own case, I still could not get CreateDriveTimeAreas to work

Can you share your sample code here so we can take a look at it.

Thanks and Regards

Ganesh Subbiah | Software Developer | JSAPI/ArcGIS Online Team

0 Kudos
Esri Contributor

The errors above is more due to a configuration setting that was needed in the above code shared.

Here is a working sample : 

All Analysis Widgets support 2 UX styles , to allow the input layer to be changed via dropdown (default) or not.

CreateDriveTimeAreas | ShowSelectAnalysisLayer

ShowSelectAnalysisLayer : Default is true

1. Create Drive Time Areas with Fixed Input Layer :  : This was based on the code above, by setting ShowSelectAnalysisLayer to false, the Widget Works

2. Create Drive Time Areas with changeable Input Layers ( step 1) 

When ShowSelectAnalysisLayer is true, Widget requires to set this property. We will add this in documentation.

inputLayers: [array of possible inputlayers]


Ganesh Subbiah | Software Developer | JSAPI/ArcGIS Online Team

0 Kudos
New Contributor III


It's a little tricky to post my code here without posting some sensitive data, but basically, I do get the Create Drive Time Areas widget to render with no visible errors.  However, when I click "Show Credits" or "Run Analysis," the container the widget is housed in scrolls up instead of running.  I'm assuming it's trying to highlight some sort of client validation error, but nothing is shown.  

I can give you more details privately if needed, but a snippet of my code to initialize the widget is below.  I am using the 3.23 version of the API that's configured automatically through a downloaded WebApp Builder application that I'm writing my own custom widget for.

                var fl = new FeatureLayer(myFeatureLayer.url, { opacity: 0.5 });
       = "My Layer";
                var cdtaOpts = {
                    inputLayer: fl, ,
                    inputLayers: [fl],
                    inputType: "point",
                    map: myMap,
                    portalUrl: "",
                    showCredits: true,
                    showSelectAnalysisLayer: true,
                    showReadyToUseLayers: false,
                    showChooseExtent: false
                var cdta = new CreateDriveTimeAreas(cdtaOpts, "createDriveTimeContainer");
0 Kudos
Esri Contributor

Hi Matt, 

Did you check this codepen CreateDriveTimeAreas  , this sample works, you need not pass ``. let me know if this is working. 

0 Kudos