Hi,
I'm trying add some symbols in my map(C++), I followed the code in the link https://developers.arcgis.com/qt/10-2/cpp/guide/create-a-graphics-layer.htm but I cant able to add a header file "GraphicsLayer.h" in my application. Showing error no such file or directory.
Solved! Go to Solution.
Hi Luke,
Thanks for your kind reply.
I changed the x, y coordinates value it worked!
Previous Value
Graphic* redCircle = new Graphic(Point(12.973318, 77.640717, SpatialReference::wgs84()), this);
Changed to
Graphic* redCircle = new Graphic(Point(77.640717, 12.973318, SpatialReference::wgs84()), this);
Hi Paulraj J, could I just confirm that your are using version 10.2.X of the SDK and not the 100.0 release?
For version 100.0, this GitHub repository (arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_CppSamples at master · Esri/arcgis-runtime-samples-qt ·... ) has some examples of the kinds of things you are doing. The code in the link you posted would not be valid
If you are using 10.2.6, perhaps you could provide some more details of how your project is set up? E.g. are you using QtCreator as your IDE?
Luke
Hi Luke,
Thanks for reply. I'm using SDK 100.0 release in QtCreator
I followed the examples in GitHub. The simple marker is displaying for online source map, but im not getting the graphic marker in my local raster map file(tif). The Lat, Long values I',m adding in graphic point, but it is not displaying, may be I'm wrong in spacial reference. pls guide me
Below is my code,
void RasterLayerFile::componentComplete()
{
QQuickItem::componentComplete();
QString dataPath = QQmlProperty::read(this, "C:\Users\TAS\ArcGIS\Runtime\Data\raster").toString();
// find QML MapView component
m_mapView = findChild<MapQuickView*>("mapView");
m_mapView->setWrapAroundMode(WrapAroundMode::Disabled);
// Create a map using a raster layer
createAndAddRasterLayer(dataPath + "Map.tif");
}
void RasterLayerFile::createAndAddRasterLayer(QUrl rasterUrl)
{
QString dataPath = rasterUrl.toLocalFile();
Raster* raster = new Raster(dataPath, this);
RasterLayer* rasterLayer = new RasterLayer(raster, this);
Basemap* basemap = new Basemap(rasterLayer, this);
m_map = new Map(basemap, this); //Offlne Tif map
//m_map = new Map(Basemap::imagery(this), this); //Online Imagery map
m_graphicsOverlay = new GraphicsOverlay(this);
Graphic* redCircle = new Graphic(Point(12.973318, 77.640717, SpatialReference::wgs84()), this);
//Graphic* redCircle = new Graphic(Point(12.973318, 77.640717, SpatialReference::webMercator()), this);
SimpleMarkerSymbol* redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor("red"), 12, this);
redCircle->setSymbol(redCircleSymbol);
m_graphicsOverlay->graphics()->append((redCircle));
m_mapView->graphicsOverlays()->append(m_graphicsOverlay);
m_mapView->setMap(m_map);
}
Hi Paulraj J,
If you add the following code to your createAndAddRasterLayer function you should see the WKID of the spatial reference from your raster layer logged to the QtCreator console:
connect(rasterLayer, &RasterLayer::doneLoading, this, [this, rasterLayer](Error loadError)
{
if (!loadError.isEmpty()){
qDebug() << loadError.message() << loadError.additionalMessage();return;}
m_mapView->setViewpointCenter(rasterLayer->fullExtent().center(), 80000);
qDebug() << "MapView wkid" << m_mapView->spatialReference().wkid();
qDebug() << "rasterLayer wkid" << rasterLayer->spatialReference().wkid();
});
For example, with a local file I am using I see:
rasterLayer wkid 26910
If the reported wkid is 0 then your raster is not getting loaded with a valid Spatial Reference and so the position that you create the graphics at will not match.
It also looks like your dataPath is missing a directory separator at the end - I think at the moment the url you are passing would be "C:\Users\TAS\ArcGIS\Runtime\Data\rasterMap.tif" - but I could be wrong.
I hope that helps,
Luke
Hi Luke,
Thanks for your kind reply.
I changed the x, y coordinates value it worked!
Previous Value
Graphic* redCircle = new Graphic(Point(12.973318, 77.640717, SpatialReference::wgs84()), this);
Changed to
Graphic* redCircle = new Graphic(Point(77.640717, 12.973318, SpatialReference::wgs84()), this);