Graphic not showing at the right coordinates

3651
2
Jump to solution
05-16-2015 06:40 AM
MarcoPiccolino1
New Contributor III

Hi,

I am having trouble with the following code.

I would expect the Graphic to show up at the specified x and y, but instead it shows up at 0,0.

Am I missing anything?

---

import QtQuick 2.3

import QtQuick.Controls 1.2

import ArcGIS.Runtime 10.25

ApplicationWindow {

    id: appWindow

    width: 800

    height: 600

    title: "arcgis template"

    GraphicsLayer {

        id: graphicsLayer

    }

    Map {

        id: map

        anchors.fill: parent

        wrapAroundEnabled: true

        focus: true

        extent: aoi

        Envelope {

            id: aoi

            spatialReference: SpatialReference {

                wkid: 4326

            }

            xMin: 9

            yMin: 45

            xMax: 10

            yMax: 47

        }

        ArcGISLocalTiledLayer {

            path: "~/ArcGIS/Runtime/Data/tpks/Topographic.tpk"

        }

        onStatusChanged: {

            if(map.status === Enums.MapStatusReady) {

                graphicsLayer.renderingMode = Enums.RenderingModeStatic;

                addLayer(graphicsLayer);

                var graphic = {

                    geometry: {

                        spatialReference: {wkid:4326},

                        x: 9.5,

                        y: 46

                    },

                    symbol: {

                        type: "esriSMS",

                        size: 10,

                        color: "blue"

                    }

                };

                var id = graphicsLayer.addGraphic(graphic);

            }

        }

    }

}

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

The issue is that the Topographic.tpk that you are using is in WGS 1984 Web Mercator Auxiliary Sphere coordinate system (wkid 102100), but the envelope and graphics you are defining are in GCS WGS 1984 (wkid 4326). These do not project on the fly, so this is why the graphic appears near 0,0. You'll need to either make a TPK that is in 4326, or the coordinates you specify in your code will need to be in 102100. You could also use our coordinate conversion class to convert units from 4326 to 102100.

Thanks,

Luke

View solution in original post

2 Replies
LucasDanzinger
Esri Frequent Contributor

The issue is that the Topographic.tpk that you are using is in WGS 1984 Web Mercator Auxiliary Sphere coordinate system (wkid 102100), but the envelope and graphics you are defining are in GCS WGS 1984 (wkid 4326). These do not project on the fly, so this is why the graphic appears near 0,0. You'll need to either make a TPK that is in 4326, or the coordinates you specify in your code will need to be in 102100. You could also use our coordinate conversion class to convert units from 4326 to 102100.

Thanks,

Luke

MarcoPiccolino1
New Contributor III

thanks Luke. I did switch a few base layers that I assumed were 4326 but apparently all of them were not

0 Kudos