ArcGisRuntime V100: Offset of PictureMarker

306
2
12-12-2016 05:46 AM
NorbertThoden
Occasional Contributor III

Hi!

On November 2015 i logged two bugs via the official support (case 01713501:

  1. 000092678 (rotation depends on RenderingMode ) http://support.esri.com/bugs/nimbus/QlVHLTAwMDA5MjY3OA==
  2. 000092680 (unclear unit of offset)

I used the esri page to observe the next steps.

I can read: "This is a bug at 10.2.x, but will be fixed with the Quartz release."

I can state: this is not fixed in V100!

The documentation of the PictureMarker/MarkerSymbol is about an Pushpin:

"Consider a PictureMarkerSymbol using the image of a pushpin. By default, the center of the image will be used as the anchor to center the image at the map location. However, if you wanted the needle of the pushpin to end at the map location, you would need to offset the image appropriately to make the needle's end coincide with the map location."

(source https://developers.arcgis.com/qt/latest/cpp/api-reference/esri-arcgisruntime-markersymbol.ht...

But pay attention: you have to take care about the GraphicsRenderingMode the Marker is displayed on!

The offset depends on the image dimensions - of course.

But in case of GraphicsRenderingMode::Static you have to rotate the offset also.

A final code could look like:

m_pictureMarkerSymbol = new Esri::ArcGISRuntime::PictureMarkerSymbol(*m_image);
QPointF markerHotSpot = QPointF(m_image->width() / 2.0 * m_markerHotSpotPercent.value().x(),
                                                          m_image->height() / 2.0 * m_markerHotSpotPercent.value().y());

QPointF finalOffset = (markerHotSpot.toPoint() * -1) * 1.33 // 1.33; // try and error (48pixel / 36pt)
                                    +
                                    (m_externalOffset.value() * 0.75); // 0.75; // try and error (36pt / 48pixel)

// hmm, in static rendering mode, the offset has to be rotated also
// (Bug 000092689 - Case 01713501 ; NOT fixed in V100.0)
// Therefore:
if (this->m_graphicsLayer->renderingMode() == Esri::ArcGISRuntime::GraphicsRenderingMode::Static)
   MathUtils::rotatePoint(finalOffset, QPointF(), m_angle.value());
m_pictureMarkerSymbol->setOffsetX(finalOffset.x());
m_pictureMarkerSymbol->setOffsetY(finalOffset.y());
m_pictureMarkerSymbol->setAngle(m_angle.value());

Maybe ESRI likes to make this part of the api consistent?

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

Regarding BUG-000092678, you are correct- it is not yet fixed in the first release of Quartz (100.0), but we are still working on it. I realize it was confusing to close it before, so I have reopened it, and it should show up as open again instead of closed. This may take a bit to get updated on the public page.

Regarding BUG-000092680, I tested with the original test data again, and I don't see the issue with version 100.0. Here is my code: 

  // create graphic overlay
  GraphicsOverlay* go = new GraphicsOverlay(this);
  m_mapView->graphicsOverlays()->append(go);

  // create simple marker graphic
  Point p(0,0);
  SimpleMarkerSymbol* ss = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle,QColor("yellow"),50,this);
  Graphic* g = new Graphic(p, ss, this);
  go->graphics()->append(g);

  // create simple marker graphic
  Point p2(0,0);
  PictureMarkerSymbol* ps = new PictureMarkerSymbol(QImage("/Users/<username>/Desktop/PictureRotation/Arrow.png"),this);
  ps->setHeight(50);
  ps->setWidth(20);
  ps->setOffsetY(-25);
  Graphic* g2 = new Graphic(p2, ps, this);
  go->graphics()->append(g2);
0 Kudos
NorbertThoden
Occasional Contributor III

Hi Luke!

Thanks for taking time for "my" old bugs!

To BUG-000092678: fine

To BUG-000092680: I didn´t checked, because my application replaces the PictureMarker if size changes.

Thanks

0 Kudos