Select to view content in your preferred language

Graphics not being updated on the map

456
5
Jump to solution
06-03-2022 01:30 AM
Aeseir
by
Frequent Contributor

I am trying to add and display graphics to a map post load.

My code is able to add it to the graphicslayer, and it advises me that it has added it.

Yet it doesn't show it on the map.

I've just spent over a day on documentation and i cannot figure it out.

 

    watchUtils.on(this.graphicsLayer, "graphics", "change", () => {console.log('Graphics added!');});


let polygon = {
      type: "polygon", // autocasts as Polygon
      rings: this.fromLATLONGtoXY(bigPolygon),
    };

    const simSymbol = {
      type: "simple-fill",
      color: [138, 43, 226, 0.5],
      style: "solid",
      outline: { 
        color: "blue",
        width: 1
      }
    }

    let graphic = new Graphic({
      geometry: polygon as Polygon,
      symbol: simSymbol
    });

    this.graphicsLayer.add(graphic);

 

After running the function i get a "Graphics added!" in console, but no graphic is  shown on map.

0 Kudos
1 Solution

Accepted Solutions
Aeseir
by
Frequent Contributor

Ended up fixing this by completely deleting the page code and starting from scratch. Essentially copy and pasting into another file and running it from that file.

It worked then, there must have been something funny going on in the cache that cause the issue.

View solution in original post

0 Kudos
5 Replies
TimDietz
Occasional Contributor

You might want to post more code to give us a better context in order to see if we can help.  Also, have you tried removing the 'as Polygon' from line 20?  I have a very simple test file and it does not use that syntax.

0 Kudos
Aeseir
by
Frequent Contributor

Removing polygon wasn't it.

There is really not much more code other than a bigPolygon that has series of LatLng that get converted to XY coordinate using the webMercatorUtils.lngLatToXY. The out put for that is correct.

0 Kudos
KenBuja
MVP Esteemed Contributor

Is the spatial reference correct?

0 Kudos
Aeseir
by
Frequent Contributor

No changes to spatial reference, they are same

0 Kudos
Aeseir
by
Frequent Contributor

Ended up fixing this by completely deleting the page code and starting from scratch. Essentially copy and pasting into another file and running it from that file.

It worked then, there must have been something funny going on in the cache that cause the issue.

0 Kudos