Select to view content in your preferred language

Property 'geometry' does not exist error when making graphic from point

161
2
Jump to solution
3 weeks ago
PeteVitt
Frequent Contributor

I'm using Javascript api 4.31 and am getting Property 'geometry' does not exist error when trying to create a graphic from a point. My code is this:

     //values of  x and y are: x=-13091490.173999999,  y=4013255.786700003
    let pt = new Point({
     x:x,
     y:y,
      spatialReference: this.sr//this is valid wkid=3857
    });
   
    let ptGraphic = new Graphic({
      geometry: pt.geometry, //error here is: Property 'geometry' does not exist on type 'Point'
    });
Any idea why I get this error, or if there is another way to do this?  My code is based on an example of making graphic from point located at:
 
// First create a point geometry
let point = {
  type: "point",  // autocasts as new Point()
  longitude: -71.2643,
  latitude: 42.0909
};

// Create a symbol for drawing the point
let markerSymbol = {
  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
  color: [226, 119, 40]
};

// Create a graphic and add the geometry and symbol to it
let pointGraphic = new Graphic({
  geometry: point,
  symbol: markerSymbol
});
I'm seeing the same error if I try to run the example code.
 
Thanks
 
Pete
 
 
 
 
 
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
WesleyO
Esri Contributor

Hi @PeteVitt ,

 

It should be

 

let ptGraphic = new Graphic({
      geometry: pt
});

View solution in original post

0 Kudos
2 Replies
WesleyO
Esri Contributor

Hi @PeteVitt ,

 

It should be

 

let ptGraphic = new Graphic({
      geometry: pt
});
0 Kudos
PeteVitt
Frequent Contributor

thanks Wesley -- thats it

0 Kudos