Create an arrow in ArcGIS QT 100.1.

592
4
10-25-2017 04:21 AM
New Contributor II

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
// 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.

1 Solution

Accepted Solutions
Esri Frequent Contributor

I just wrote up a blog about how you could author a custom symbol in Pro, and then consume this in Runtime. I think this would be the optimal way to achieve this workflow - https://community.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-qt/blog...

4 Replies
Esri Frequent Contributor

I just wrote up a blog about how you could author a custom symbol in Pro, and then consume this in Runtime. I think this would be the optimal way to achieve this workflow - https://community.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-qt/blog...

New Contributor II

Thanks for the example, Lucas, could I ask you for a small prompt? In your article you have showed step by step rules for create custom symbol in arcgis pro, but you started it with following lines:

• Insert a new map and add some vector data to your map

There are some problems, how can I add this vector data. Could you show this step. I founded styles in pro's catalog and in the contents, but how can I add this vector data which you talking about? I want to create an yellow arrow. It couldn't be done with this tables.

Esri Frequent Contributor

There is now an even simpler way to do this with 100.2. You can make use of the SimpleLineMarkerSymbolStyle and SimpleLineSymbolMarkerPlacement

``  // find QML MapView component  m_mapView = findChild<MapQuickView*>("mapView");  // Create a map using the topographic basemap  m_map = new Map(Basemap::topographic(this), this);  // Set map to map view  m_mapView->setMap(m_map);  // Create and add Graphics  m_graphicsOverlay = new GraphicsOverlay(this);  m_mapView->graphicsOverlays()->append(m_graphicsOverlay);  PolylineBuilder* builder = new PolylineBuilder(SpatialReference::wgs84(), this);  builder->addPoint(-45,-25);  builder->addPoint(45,0);  builder->addPoint(-45, 25);  m_lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor("red"), 3.0f, this);  m_lineSymbol->setMarkerStyle(SimpleLineSymbolMarkerStyle::Arrow);  m_lineSymbol->setMarkerPlacement(SimpleLineSymbolMarkerPlacement::Begin);  Graphic* graphic = new Graphic(builder->toGeometry(), m_lineSymbol, this);  m_graphicsOverlay->graphics()->append(graphic);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``
New Contributor II

Thanks , I use it !