Missing value for required property 'x' on 'esri.geometry.Point'

109
2
09-28-2022 02:17 PM
GeraldRowe
New Contributor

Can anyone tell me why I'm getting the error in the title using the code below? I'm about at my wits end with Esri. I literally copied the simplest example of creating a graphic and placing it on a map that I can find and it still doesn't work. Anytime I try to create a point, it throws this exception. It works fine(no exception) if I add "x: 0, y: 0" to the point geometry, but then I get a Point somewhere in the Atlantic somewhere near Africa; presumably because the easting/northing values are 0. It just seems to ignore the geo coordinates. I need to use only lat/lon values.

 

const simpleMarkerSymbol = {
type: "simple-marker",
color: [255, 0, 0],
outline: { color: [255, 255, 255], width: 0 }
};

const pointGraphic = new Graphic(
{
geometry: { type: "point", longitude: location.lon, latitude: location.lat },
symbol: simpleMarkerSymbol
}
);

graphicsLayer.add(pointGraphic);

 

Yes the map, layers, etc are all running fine and the lat/lon values are verified present and sane. It's just the Point that doesn't show because of the above exception.

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor II

Not sure. Do you have a codepen or github showing the issue?

Using your code here with some values and seems to work, could be something else.

https://codepen.io/odoe/pen/wvjyxvj?editors=1000

0 Kudos
JoelBennett
Occasional Contributor III

Have you tried specifying the "x" and "y" properties instead of "latitude" and "longitude"?  The error message suggests this might solve the problem.  For example:

geometry: { type: "point", x: location.lon, y: location.lat },

 

The default spatial reference when not explicitly specified is WGS 84, so I would expect this to work.

0 Kudos