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);
}
}
}
}
Solved! Go to Solution.
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
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
thanks Luke. I did switch a few base layers that I assumed were 4326 but apparently all of them were not