AnsweredAssumed Answered

ArcGisRuntime V100: Offset of PictureMarker

Question asked by norbert.thoden on Dec 12, 2016
Latest reply on Dec 13, 2016 by norbert.thoden

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.html#details)

 

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?

Outcomes