<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to set SpatialReference in C++ in Qt Maps SDK Questions</title>
    <link>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063231#M4187</link>
    <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I'm trying to use ArcGIS with C++.&lt;/P&gt;&lt;P&gt;I don't know how to set&amp;nbsp; SpatialReference for maps in C++.&lt;/P&gt;&lt;P&gt;Is there any way to do this other than setting it up in the new Map()?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;header:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#ifndef CPPMAPS_H
#define CPPMAPS_H

namespace Esri
{
namespace ArcGISRuntime
{
class Map;
class MapQuickView;
}
}

#include &amp;lt;QObject&amp;gt;
#include &amp;lt;QMouseEvent&amp;gt;

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 &amp;amp;mouseEvent);

private:
    MapQuickView* mapView() const;
    void setMapView(MapQuickView* mapView);

    Map* m_map = nullptr;
    MapQuickView* m_mapView = nullptr;

    //SpatialReference sp(6668);  &amp;lt;-GetError
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cpp:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include "CppMaps.h"

#include "Basemap.h"
#include "Map.h"
#include "MapQuickView.h"
#include &amp;lt;QUrl&amp;gt;

CppMaps::CppMaps(QObject* parent /* = nullptr */):   QObject(parent)
{
        m_map = new Map(BasemapStyle::ArcGISTopographic, this);
}

CppMaps::~CppMaps()
{
}

MapQuickView* CppMaps::mapView() const
{
    qDebug() &amp;lt;&amp;lt; "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-&amp;gt;setMap(m_map);

    qDebug() &amp;lt;&amp;lt; m_map-&amp;gt;spatialReference().wkid();

    connect(m_mapView, &amp;amp;MapQuickView::mouseClicked, this, &amp;amp;CppMaps::fnSlotTest);

    emit mapViewChanged();
}

void CppMaps::fnSlotTest(QMouseEvent &amp;amp;mouseEvent)
{
    qDebug() &amp;lt;&amp;lt; mouseEvent.x();
    qDebug() &amp;lt;&amp;lt; mouseEvent.y();

    const Point cPoint = m_mapView-&amp;gt;screenToLocation(mouseEvent.x(), mouseEvent.y());

    qDebug() &amp;lt;&amp;lt; cPoint.x();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 May 2021 23:46:55 GMT</pubDate>
    <dc:creator>Kanzakiryu</dc:creator>
    <dc:date>2021-05-31T23:46:55Z</dc:date>
    <item>
      <title>How to set SpatialReference in C++</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063231#M4187</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I'm trying to use ArcGIS with C++.&lt;/P&gt;&lt;P&gt;I don't know how to set&amp;nbsp; SpatialReference for maps in C++.&lt;/P&gt;&lt;P&gt;Is there any way to do this other than setting it up in the new Map()?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;header:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#ifndef CPPMAPS_H
#define CPPMAPS_H

namespace Esri
{
namespace ArcGISRuntime
{
class Map;
class MapQuickView;
}
}

#include &amp;lt;QObject&amp;gt;
#include &amp;lt;QMouseEvent&amp;gt;

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 &amp;amp;mouseEvent);

private:
    MapQuickView* mapView() const;
    void setMapView(MapQuickView* mapView);

    Map* m_map = nullptr;
    MapQuickView* m_mapView = nullptr;

    //SpatialReference sp(6668);  &amp;lt;-GetError
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cpp:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include "CppMaps.h"

#include "Basemap.h"
#include "Map.h"
#include "MapQuickView.h"
#include &amp;lt;QUrl&amp;gt;

CppMaps::CppMaps(QObject* parent /* = nullptr */):   QObject(parent)
{
        m_map = new Map(BasemapStyle::ArcGISTopographic, this);
}

CppMaps::~CppMaps()
{
}

MapQuickView* CppMaps::mapView() const
{
    qDebug() &amp;lt;&amp;lt; "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-&amp;gt;setMap(m_map);

    qDebug() &amp;lt;&amp;lt; m_map-&amp;gt;spatialReference().wkid();

    connect(m_mapView, &amp;amp;MapQuickView::mouseClicked, this, &amp;amp;CppMaps::fnSlotTest);

    emit mapViewChanged();
}

void CppMaps::fnSlotTest(QMouseEvent &amp;amp;mouseEvent)
{
    qDebug() &amp;lt;&amp;lt; mouseEvent.x();
    qDebug() &amp;lt;&amp;lt; mouseEvent.y();

    const Point cPoint = m_mapView-&amp;gt;screenToLocation(mouseEvent.x(), mouseEvent.y());

    qDebug() &amp;lt;&amp;lt; cPoint.x();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2021 23:46:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063231#M4187</guid>
      <dc:creator>Kanzakiryu</dc:creator>
      <dc:date>2021-05-31T23:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to set SpatialReference in C++</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063640#M4191</link>
      <description>&lt;P&gt;The spatial reference can be set in one of two ways. The first, most common way, is to add a layer to your map. The first layer, typically the basemap, will dictate what the spatial reference of the map will be. In the case of the ArcGIS Basemaps, most are in Web Mercator, so a map created with these basemaps will be in web mercator. The second option is to explicitly instantiate a map with a SpatialReference object, and then add your layers to your map after. The caveat here is that some layers, such as tiled layer/vector tiled layer basemaps, do not support reprojecting on the fly, so you will need to use layers that can be projected on the fly or publish your own basemap data in the spatial reference you choose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More info on spatial references can be found here -&amp;nbsp;&lt;A href="https://developers.arcgis.com/qt/spatial-and-data-analysis/spatial-references/" target="_blank"&gt;https://developers.arcgis.com/qt/spatial-and-data-analysis/spatial-references/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 15:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063640#M4191</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2021-06-01T15:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set SpatialReference in C++</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063929#M4194</link>
      <description>&lt;P&gt;OK, It worked.&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 02:47:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/how-to-set-spatialreference-in-c/m-p/1063929#M4194</guid>
      <dc:creator>Kanzakiryu</dc:creator>
      <dc:date>2021-06-02T02:47:03Z</dc:date>
    </item>
  </channel>
</rss>

