I am creating/drawing a new polyline successfully; the only problem is it's going under my other graphic layers. Is there any ability to set the z-index of this to bring it above the over layers? I read in 4.x there is this ability with 'collections' but I find the documentation very vague.

  var graphicsLayer = new GraphicsLayer();

  var simpleLineSymbol = {
      type: "simple-line",
      color: [13, 121, 190, 1],
      style: "short-dash",
      width: 5

    var polyline = {
        type: "polyline",
        paths: [
            [lineY, lineX],
            [coordinatesBx, coordinatesBy]
    var polylineGraphic = new Graphic({
        geometry: polyline,
        symbol: simpleLineSymbol
  • Did you try specifying an index when calling the add method? Jan 17, 2020 at 1:18
  • This is how I am adding it; graphicsLayer.add(polylineGraphic) Jan 17, 2020 at 1:23
  • Yeah I dont really understand the example in that documentation, I find their documentation not very explicit Jan 17, 2020 at 1:24

1 Answer 1


If the problem is the graphics in the same layer, then you can play with the order of the graphics (check @Kirk Kyukendall comment). By default, the graphics are added to the end of the list so it is render on top of the other graphics of the layer. You can think the index of the graphics in the list as their z.

If the problem are other graphics from another layer, then you can play with the order of the layers in the map. The layers are render in the order of the list. The usual order is polygons, then lines, then points.

  • That is problem the points are overlapping my new PolyLine so you can barely see the lines Jan 17, 2020 at 17:20
  • 1
    I know what you mean, making a map is an art. I suggest you that instead of trying to resolve it by "code", your work on the style of the layers, try different size, colors, markers, etc.
    – cabesuon
    Jan 17, 2020 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.