Select to view content in your preferred language

issue with trying to display graphic on map

269
2
10-28-2022 12:21 PM
abdulsaheeddurodola
Emerging Contributor

Hi all,

I am trying to develop a widget for my organization. It would automatically create graphics. I will be using web app builder developer to build this widget

Method:function()
{
    this.graphicsLayer = new GraphicsLayer();
   
   this.map.addLayer(this.graphicsLayer);//graphics layer in Map.graphics

  let des_paths=[
[-79.038452,43.894920],
 
[-79.038452,43.89426],
  ]
 
const polyline = {
type: "polyline",
paths:des_paths
};
const simpleLineSymbol = {
type: "simple-line",
color: "blue", // Orange
width: 100
};

const polylineGraphic = new Graphic({
geometry: polyline,
symbol: simpleLineSymbol
});
console.log(this.graphicsLayer);
this.graphicsLayer.add(polylineGraphic);

/////

const point = { //Create a point
  type: "point",
  longitude: -79.038452,
  latitude: 43.894920
};

const simpleMarkerSymbol = {
  type: "simple-marker",
  color: [226, 119, 40],  // Orange
  outline: {
      color: [255, 255, 255], // White
      width: 1
  }
};
const pointGraphic = new Graphic({
  geometry: point,
  symbol: simpleMarkerSymbol
});

this.graphicsLayer.add(pointGraphic);
 
//
}
I do not see any of the 2 graphics on the map


0 Kudos
2 Replies
BrianLeroux
Frequent Contributor

There is likely more than one issue here. I don't think you should use this.graphicsLayer. I would declare that as a variable using var graphicsLayer . You should really leverage the API documentation and samples to help you through this especially if this is your first time developing with ArcGIS.  https://developers.arcgis.com/javascript/3/jssamples/graphics_create_circles.html 

0 Kudos
abdulsaheeddurodola
Emerging Contributor

Thanx for the reply brian. I am new to WAB so what other issue could be wrong here. Would appreciate additional tips. Thanks

0 Kudos