Hello.
I'm trying to use ArcGIS with C++.
I don't know how to set SpatialReference for maps in C++.
Is there any way to do this other than setting it up in the new Map()?
header:
#ifndef CPPMAPS_H
#define CPPMAPS_H
namespace Esri
{
namespace ArcGISRuntime
{
class Map;
class MapQuickView;
}
}
#include <QObject>
#include <QMouseEvent>
using namespace Esri::ArcGISRuntime;
class CppMaps : public QObject
{
Q_OBJECT
Q_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged)
public:
explicit CppMaps(QObject* parent = nullptr);
~CppMaps() override;
signals:
void mapViewChanged();
public slots:
void fnSlotTest(QMouseEvent &mouseEvent);
private:
MapQuickView* mapView() const;
void setMapView(MapQuickView* mapView);
Map* m_map = nullptr;
MapQuickView* m_mapView = nullptr;
//SpatialReference sp(6668); <-GetError
};
cpp:
#include "CppMaps.h"
#include "Basemap.h"
#include "Map.h"
#include "MapQuickView.h"
#include <QUrl>
CppMaps::CppMaps(QObject* parent /* = nullptr */): QObject(parent)
{
m_map = new Map(BasemapStyle::ArcGISTopographic, this);
}
CppMaps::~CppMaps()
{
}
MapQuickView* CppMaps::mapView() const
{
qDebug() << "TEST";
return m_mapView;
}
// Set the view (created in QML)
void CppMaps::setMapView(MapQuickView* mapView)
{
if (!mapView || mapView == m_mapView)
{
return;
}
m_mapView = mapView;
m_mapView->setMap(m_map);
qDebug() << m_map->spatialReference().wkid();
connect(m_mapView, &MapQuickView::mouseClicked, this, &CppMaps::fnSlotTest);
emit mapViewChanged();
}
void CppMaps::fnSlotTest(QMouseEvent &mouseEvent)
{
qDebug() << mouseEvent.x();
qDebug() << mouseEvent.y();
const Point cPoint = m_mapView->screenToLocation(mouseEvent.x(), mouseEvent.y());
qDebug() << cPoint.x();
}