SimpleMarkerSymbol using meters

128
2
Jump to solution
03-27-2024 08:20 AM
Tom_Prutz
New Contributor II

Good Afternoon

I am trying to create a cross on my map using a SimpleMarkerSymbol. This will be attached to the mouse pointer and is to be used for quick eyeball measuring. As such I need it to be a specific size e.g. 10 meters. I would like it to be a graphic that I can add to my graphics layer.

However the SimpleMarkerSymbol only takes sizes in pixels and points. Pixels can vary depending on the display equipment and I can't find any documentation to help me understand how points would relate to meters.

For other things like the Circle (https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html) I can specify a radius in meters and then use a fill symbol to create a visual that matches the size. i.e. by specifying a radius of 5 meters and then add a Simple FillSymbol I end up with a visible 10 meter circle.

There isn't a cross equivalent of the circle (that I can find) and I can't provide a meter measurement to the only cross element I can find (the SimpleMarkerSymbol) so I'm at a bit of a loss as to how to achieve this. Should I be converting meters to points and if so what is the conversion rate? If not what is the recommended way to achieve this?

Any help or advice would be appreciated.

1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

Rather than using a SimpleMarkerSymbol, you might try something like this:

  1. Create a Circle with the 5 meter radius.
  2. Using the circle's extent, determine the four endpoints for the cross.
  3. Create a Polyline with 2 paths, one path being the vertical line, and one path being the horizontal line.
  4. Create a Graphic with the polyline as the geometry, and a SimpleLineSymbol as the symbol.
  5. Add the graphic to the view's graphics or some other GraphicsLayer.
  6. Whenever the mouse moves:
    1. Calculate the distance between the map location of the cursor and the center of the polyline's extent.
    2. Translate the polyline so it's centered at the mouse's location.

View solution in original post

0 Kudos
2 Replies
JoelBennett
MVP Regular Contributor

Rather than using a SimpleMarkerSymbol, you might try something like this:

  1. Create a Circle with the 5 meter radius.
  2. Using the circle's extent, determine the four endpoints for the cross.
  3. Create a Polyline with 2 paths, one path being the vertical line, and one path being the horizontal line.
  4. Create a Graphic with the polyline as the geometry, and a SimpleLineSymbol as the symbol.
  5. Add the graphic to the view's graphics or some other GraphicsLayer.
  6. Whenever the mouse moves:
    1. Calculate the distance between the map location of the cursor and the center of the polyline's extent.
    2. Translate the polyline so it's centered at the mouse's location.
0 Kudos
Tom_Prutz
New Contributor II

Hi Joel

That worked really well thank you, problem solved.

I still find it a little weird that I can specify meters as a size option for my marker symbol but for now at least that doesn't matter.

Thank you very much for taking the time to post such a good solution!

0 Kudos