AnsweredAssumed Answered

Create an arrow in ArcGIS QT 100.1.

Question asked by FerrariRace on Oct 25, 2017
Latest reply on Jan 15, 2018 by FerrariRace

Hi ERSI !  I want to create arrow that would be connect 2 points on a map, and show a direction from one mark to another. I saw similar question from one person in this Community. But i don't understand how create correct direction for triangle. 

Right now i use something like this:

 

(Was taken from Geometrics ersi example.)

 

  // create line geometry
  PolygonBuilder polylineBuilder(SpatialReference::wgs84());
  // build the polyline
  polylineBuilder.addPoint(-110.829004, 44.462438);
  polylineBuilder.addPoint(-110.828140, 44.460458);
  // create a line symbol
  SimpleLineSymbol* sls = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor("blue"), 2, this);
  // create a line graphic
  Graphic* lineGraphic = new Graphic(polylineBuilder.toGeometry(), this);

 

  // create a graphic overlay to display the line graphic
  GraphicsOverlay* lineGraphicOverlay = new GraphicsOverlay(this);
  // set the renderer of the graphic overlay to be the line symbol
  lineGraphicOverlay->setRenderer(new SimpleRenderer(sls, this));
  // add the graphic to the overlay
  lineGraphicOverlay->graphics()->append(lineGraphic);
  // add the overlay to the mapview
  m_mapView->graphicsOverlays()->append(lineGraphicOverlay);

 

This line connect 2 points which presents coordinates of head and tail of this arrow. So what's the question. I want to create arrow that starts from end point to start point, with correct angle of rotation for triangle object that presents direction,  which would be connected to the line object. I have only 2 points (I mean coordinates in wgs), so somehow i have to calculate correct angle between them, for rotating of triangle. Also, when one of this 2 points would  move, the arrow that belongs for one of this points should be changed. What's the better way to do that? I mean recalculate direction of triangle and line dynamically, with points movement.

Outcomes