I'm trying to populate 3d line using ArcGIS API for JavaScript with my ArcGIS online PipeLine url, but somehow I'am not able to populate. I have attached the code

381
5
11-05-2019 06:15 PM
NavyaNa
New Contributor
<script>       require([         "esri/Map",         "esri/views/SceneView",         "esri/layers/FeatureLayer",         "esri/widgets/Legend"       ], function(Map, SceneView, FeatureLayer, Legend) {    var map = new Map({          basemap: "topo-vector",            ground: "world-elevation"         });          var view = new SceneView({           container: "viewDiv",           map: map,           zoom: 15,           center: [103.805699, 1.276566],            heading: 300,            tilt: 75        });          const options = {           profile: "quad",           cap: "round",           join: "miter",           width: 5,           height: 30,           color: [200, 200, 200],           profileRotation: "all"         };          var renderer = {            defaultSymbol: {             type: "polygon-3d",         symbolLayers: [                     {                       type: "path",                       profile: options.profile,                       width: options.width,                       height: options.height,                       join: options.join,                       cap: options.cap,                       anchor: "bottom",                       profileRotation: options.profileRotation                     }                   ]           }         };          const PipelineLayer = new FeatureLayer({           url:             "https://services6.arcgis.com/itEfD6Bf5W0iWJuO/arcgis/rest/services/PipeLine1/FeatureServer/0",           elevationInfo: {             mode: "relative-to-ground",             offset: 3           },          renderer:renderer         });         map.add(PipelineLayer);        });     </script>
Tags (1)
0 Kudos
5 Replies
RalucaNicola1
Esri Contributor

Hey,

You've got a bunch of errors in the code: you should specify the renderer type (I assume it's a SimpleRenderer), then the `defaultSymbol` becomes `symbol`. Your line symbols should have a `line-3d` type, not a `polygon-3d` type. Also it's important that you specify the color, otherwise you won't see anything.

Here's how the code would look like with the changes mentioned above:

require([
  "esri/Map",
  "esri/views/SceneView",
  "esri/layers/FeatureLayer",
  "esri/widgets/Legend"
], function(Map, SceneView, FeatureLayer, Legend) {
  var map = new Map({ basemap: "topo-vector", ground: "world-elevation" });
  var view = new SceneView({
    container: "viewDiv",
    map: map,
    zoom: 15,
    center: [103.805699, 1.276566],
    heading: 300,
    tilt: 75
  });
  const options = {
    profile: "quad",
    cap: "round",
    join: "miter",
    width: 5,
    height: 30,
    color: [200, 200, 200],
    profileRotation: "all"
  };
  var renderer = {
    type: "simple",
    symbol: {
      type: "line-3d",
      symbolLayers: [
        {
          type: "path",
          profile: options.profile,
          width: options.width,
          height: options.height,
          material: {
            color: options.color
          },
          join: options.join,
          cap: options.cap,
          anchor: "bottom",
          profileRotation: options.profileRotation
        }
      ]
    }
  };
  const PipelineLayer = new FeatureLayer({
    url:
      "https://services6.arcgis.com/itEfD6Bf5W0iWJuO/arcgis/rest/services/PipeLine1/FeatureServer/0",
    elevationInfo: { mode: "relative-to-ground", offset: 3 },
    renderer: renderer
  });
  map.add(PipelineLayer);
});
0 Kudos
NavyaNa
New Contributor

Thankyou raluca Nicola, i tried with the code modified by you ,now i getting Line..but not aligned exact position, can you please suggest what to do for proper Alignment, if you do it would be great help for me 

0 Kudos
RalucaNicola1
Esri Contributor

Hi Navya,

I can't access your service. Do your features come with z values? If you make it public, I can have a look.

Generally though, we only align lines with the ground at the point where they have vertices. So to get a better alignment you might also need to densify the vertices. (no need to modify your original data, you can also do it with geometryEngine.densify()).

And for more info on different elevation modes you can read about it here: FeatureLayer | ArcGIS API for JavaScript 4.13 

0 Kudos
LahariPriya
New Contributor

Thankyou Raluca Nicola,yes my features come with Z values, i will go through with the link sent by you...thank you, for sharing knowledge. 

0 Kudos
RalucaNicola1
Esri Contributor

oh I see, if your z values match the terrain elevation then you could se `elevationInfo.mode = "absolute-height"`. If they don't match then maybe try setting the `elevationInfo.mode = "relative-to-scene"`. That ignores z values and aligns the vertices on your lines to the ground (but also extruded polygons and buildings in case you have that in your scene!).

0 Kudos