show popup near Graphic

3090
5
Jump to solution
05-13-2015 08:39 AM
MarcoPiccolino
New Contributor

I want to show a popup next to a graphic that I selected with findGraphics.

I guess a way to do this is to get the Graphic's geometry x and y and show my popup there.

Is this correct? if so, how do I access the Graphic's x and y?

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

I would use the mouseClicked signal on the map for this. This signal passes a MouseEvent object with it ArcGIS Runtime SDK for Qt (QML API): Map

From that, you can get the screen coordinates and the map coordinates.

ArcGIS Runtime SDK for Qt (QML API): MouseEvent

Perhaps you could then place your components location somewhere near this?

View solution in original post

5 Replies
MarcoPiccolino
New Contributor

so far I have been able to get the geometry's envelope x and y in map coordinates - how do I convert those to screen coordinates?

0 Kudos
LucasDanzinger
Esri Frequent Contributor

I would use the mouseClicked signal on the map for this. This signal passes a MouseEvent object with it ArcGIS Runtime SDK for Qt (QML API): Map

From that, you can get the screen coordinates and the map coordinates.

ArcGIS Runtime SDK for Qt (QML API): MouseEvent

Perhaps you could then place your components location somewhere near this?

MarcoPiccolino
New Contributor

Thanks Luke.

I see a difficulty in that I am currently calling findGraphics in a onMousePressed event, but then deal with the result in the GraphicLayer's onFindGraphicsComplete. Here's the code:

GraphicsLayer {

    id: gl

    renderingMode: Enums.RenderingModeStatic

    onFindGraphicsComplete: {

        gl.clearSelection();

        if (graphicIDs[0]) {

            gl.selectGraphic(graphicIDs[0]);

            console.log(graphicIDs[0])

        }

    }

}

onMousePressed: {

    var tolerance = Qt.platform.os === "ios" || Qt.platform.os === "android" ? 4 : 1;

    gl.findGraphics(mouse.x, mouse.y, tolerance * scaleFactor, 1)

}

0 Kudos
MarcoPiccolino
New Contributor

I'm being silly, I just need to store the mouse.x and mouse.y values...

0 Kudos
MarcoPiccolino
New Contributor

Yes it work well enough, thanks!

0 Kudos