Select to view content in your preferred language

Make a polyline/polygon of arrows

2013
3
Jump to solution
09-06-2017 06:57 AM
NicholasLiccini
Emerging Contributor

Hi!

I would like to indicate the direction of flow for a polyline and also for a polygon. I'd like each segment of the multipart to have an arrowhead (or just a triangle graphic) at the tip. What tools does ArcGIS for Qt/C++ have for something like this? How would I go about making arrows?

Thank you!

Nick

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi Nicholas,

assuming you can determine the angle you would like to show your arrows at for each segment, you could achieve something like this by adding SimpleMarkerSymbols, with the style set to Triangle. If you use a renderer with a rotation expression you can set an attribute on each Graphic to rotate to your desired angle. The code below shows a simple example:

  GraphicsOverlay* overlay = new GraphicsOverlay(this);
  m_mapView->graphicsOverlays()->append(overlay);
  SimpleMarkerSymbol* symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Triangle, Qt::red, 25, this);
  Graphic* g1 = new Graphic(Point(0., 0., SpatialReference::wgs84()), this);
  g1->attributes()->insertAttribute("ANGLE", 10);
  overlay->graphics()->append(g1);
  Graphic* g2 = new Graphic(Point(51., 0., SpatialReference::wgs84()), this);
  g2->attributes()->insertAttribute("ANGLE", 45);
  overlay->graphics()->append(g2);
  Graphic* g3 = new Graphic(Point(51., 22., SpatialReference::wgs84()), this);
  g3->attributes()->insertAttribute("ANGLE", 28);
  overlay->graphics()->append(g3);
  SimpleRenderer* renderer = new SimpleRenderer(symbol, this);
  renderer->setRotationExpression("[ANGLE]");
  overlay->setRenderer(renderer);

If you would like to more complex arrow symbols, there are probably two approaches you could take:

1. Use a PictureMarkerSymbol with an image of your arrow

2. Use a CompositeSymbol to combine several SimpleMarkerSymbols (e.g. a Triangle and a Square) to make the arrow shape

I hope that helps,

Luke

View solution in original post

0 Kudos
3 Replies
LukeSmallwood
Esri Contributor

Hi Nicholas,

assuming you can determine the angle you would like to show your arrows at for each segment, you could achieve something like this by adding SimpleMarkerSymbols, with the style set to Triangle. If you use a renderer with a rotation expression you can set an attribute on each Graphic to rotate to your desired angle. The code below shows a simple example:

  GraphicsOverlay* overlay = new GraphicsOverlay(this);
  m_mapView->graphicsOverlays()->append(overlay);
  SimpleMarkerSymbol* symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Triangle, Qt::red, 25, this);
  Graphic* g1 = new Graphic(Point(0., 0., SpatialReference::wgs84()), this);
  g1->attributes()->insertAttribute("ANGLE", 10);
  overlay->graphics()->append(g1);
  Graphic* g2 = new Graphic(Point(51., 0., SpatialReference::wgs84()), this);
  g2->attributes()->insertAttribute("ANGLE", 45);
  overlay->graphics()->append(g2);
  Graphic* g3 = new Graphic(Point(51., 22., SpatialReference::wgs84()), this);
  g3->attributes()->insertAttribute("ANGLE", 28);
  overlay->graphics()->append(g3);
  SimpleRenderer* renderer = new SimpleRenderer(symbol, this);
  renderer->setRotationExpression("[ANGLE]");
  overlay->setRenderer(renderer);

If you would like to more complex arrow symbols, there are probably two approaches you could take:

1. Use a PictureMarkerSymbol with an image of your arrow

2. Use a CompositeSymbol to combine several SimpleMarkerSymbols (e.g. a Triangle and a Square) to make the arrow shape

I hope that helps,

Luke

0 Kudos
NicholasLiccini
Emerging Contributor

Thank you Luke! That definitely will get me started

Is there any way to determine the angle of a segment from the geometry itself rather than hardcoding it?

Thanks again,

Nick

0 Kudos
LukeSmallwood
Esri Contributor

H Nicholas, if you can walk the vertices of the geometry (e.g. using ImmutablePartCollection and so on) you should be able to use the distanceGeodetic method on GeometryEngine (GeometryEngine Class | ArcGIS for Developers ) to determine the azimuth from the start to the end point of your segments.