2

I'm creating an onClick eventhandler to create a point on every click on the map, but the Graphics layer is not visible; Has anyone else encountered this? Is there something special I'm supposed to do to show it?

Here is some of the code:


        var point = {
            type: "point",
            longitude: event.mapPoint.longitude,
            latitude: event.mapPoint.latitude,
            spatialReference: event.spatialReference,
        };
       
       var simpleMarkerSymbol = {
         type: "simple-marker",
         size: "50px",
         color: [226, 119, 40], // orange
         outline: {
           color: [255, 255, 255], // white
           width: 1
         }
       };
       
       var pointGraphic = new Graphic({
         geometry: point,
         symbol: simpleMarkerSymbol
       });
       
     let pointLayer = this.map.findLayerById("pointLayer") as GraphicsLayer;
     pointLayer.removeAll();
     pointLayer.visible=true;
     pointLayer.add(pointGraphic);
     this.logger.info("nb of graphics : ", pointLayer.graphics.length)
    
     });
 };

1 Answer 1

0

That all looks correct - you should double check you have valid values for the latitude and longitude and spatial reference (you should use wkid: 4326).

Also, try adding style: "square" to the simpleMarkerSymbol.

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.