<?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 Re: Invalid viewpoint value in onViewpointChanged event in Qt Maps SDK Questions</title>
    <link>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325021#M5016</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous User. I gave your code a spin on macOS with Qt 5.15.2 using our 100.15.0 release. It looks ok for me. I modified one of our out-of-the-box templates with your code and it prints fine. Are there any additional details you can share so we can help troubleshoot?&lt;/P&gt;&lt;P&gt;Here's what I tried. I also applied an API key locally for testing.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import QtQuick 2.12
import QtQuick.Controls 2.12
import Esri.ArcGISRuntime 100.15

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "Untitled445"

    MapView {
        id: mapView
        anchors.fill: parent
        focus: true

        onViewpointChanged: {
              updateSomeInfo()
          }

          function updateSomeInfo() {
              if (!mapView.currentViewpointCenter) {
                  console.log("it's null");
                  return;
              }

              var centerPoint = mapView.currentViewpointCenter.center;
              console.log(JSON.stringify(centerPoint.json));
          }

        Map {
            initBasemapStyle: Enums.BasemapStyleArcGISStreets
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As soon as it starts and I begin interacting the map, I see the logging:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Initializing application&lt;BR /&gt;Esri.ArcGISRuntime.Plugin: virtual void ArcGISRuntimePlugin::registerTypes(const char *) Esri.ArcGISRuntime&lt;BR /&gt;Esri.ArcGISRuntime.Plugin: static void QmlUtils::registerTypes(const char *) Esri.ArcGISRuntime&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":0,"y":0}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":0,"y":0}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-1740.0984933674335,"y":509.2080693356693}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-697460.4504242502,"y":204099.07298399135}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-701574.0835914724,"y":205318.75499369204}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-704368.3717440777,"y":206153.8160307184}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-1326097.7183212154,"y":391954.96628710814}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-1327220.7128490992,"y":392293.60304021835}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Fri, 01 Sep 2023 23:47:26 GMT</pubDate>
    <dc:creator>JamesBallard1</dc:creator>
    <dc:date>2023-09-01T23:47:26Z</dc:date>
    <item>
      <title>Invalid viewpoint value in onViewpointChanged event</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1324686#M5014</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My application MapView catches&amp;nbsp;onViewpointChanged event and makes some calculations. Simplified code looks like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        MapView {
            id: mapView

            onViewpointChanged: {
                updateSomeInfo()
            }

            function updateSomeInfo() {
                if(typeof mapView.currentViewpointCenter === "undefined" || mapView.currentViewpointCenter == null) {
                    return
                }
                if(!mapView.currentViewpointCenter) {
                    return
                }

                // error here
                var centerPoint = mapView.currentViewpointCenter.center

            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Application sometimes returns error on line #17:&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class=""&gt;TypeError: Cannot read property 'center' of null&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;I don't know how I need to check availability of&amp;nbsp;mapView.currentViewpointCenter property value and don't get error. It looks like that&amp;nbsp;mapView.currentViewpointCenter content changes in my event processing time.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Can someone help me?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 12:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1324686#M5014</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-09-01T12:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid viewpoint value in onViewpointChanged event</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325021#M5016</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous User. I gave your code a spin on macOS with Qt 5.15.2 using our 100.15.0 release. It looks ok for me. I modified one of our out-of-the-box templates with your code and it prints fine. Are there any additional details you can share so we can help troubleshoot?&lt;/P&gt;&lt;P&gt;Here's what I tried. I also applied an API key locally for testing.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import QtQuick 2.12
import QtQuick.Controls 2.12
import Esri.ArcGISRuntime 100.15

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "Untitled445"

    MapView {
        id: mapView
        anchors.fill: parent
        focus: true

        onViewpointChanged: {
              updateSomeInfo()
          }

          function updateSomeInfo() {
              if (!mapView.currentViewpointCenter) {
                  console.log("it's null");
                  return;
              }

              var centerPoint = mapView.currentViewpointCenter.center;
              console.log(JSON.stringify(centerPoint.json));
          }

        Map {
            initBasemapStyle: Enums.BasemapStyleArcGISStreets
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As soon as it starts and I begin interacting the map, I see the logging:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Initializing application&lt;BR /&gt;Esri.ArcGISRuntime.Plugin: virtual void ArcGISRuntimePlugin::registerTypes(const char *) Esri.ArcGISRuntime&lt;BR /&gt;Esri.ArcGISRuntime.Plugin: static void QmlUtils::registerTypes(const char *) Esri.ArcGISRuntime&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":0,"y":0}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":0,"y":0}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-1740.0984933674335,"y":509.2080693356693}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-697460.4504242502,"y":204099.07298399135}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-701574.0835914724,"y":205318.75499369204}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-704368.3717440777,"y":206153.8160307184}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-1326097.7183212154,"y":391954.96628710814}&lt;BR /&gt;qml: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-1327220.7128490992,"y":392293.60304021835}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 01 Sep 2023 23:47:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325021#M5016</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2023-09-01T23:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid viewpoint value in onViewpointChanged event</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325094#M5018</link>
      <description>&lt;P&gt;I have found that error only on different Android devices. It happens&amp;nbsp;&lt;SPAN&gt;very rarely. Application is used for river navigation so that event fires many times during navigation time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have added different types of checking for validity of&amp;nbsp;mapView.currentViewpointCenter. But error still happens. In one of ArcGIS AppStudio samples I have found code where&amp;nbsp;mapView.currentViewpointCenter assigns to const:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const viewpointCenter = mapView.currentViewpointCenter&lt;/LI-CODE&gt;&lt;P&gt;Then uses assigned value in code.&lt;/P&gt;&lt;P&gt;I am not expert in QT but maybe it could be way to avoid error.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2023 19:12:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325094#M5018</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-09-02T19:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid viewpoint value in onViewpointChanged event</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325449#M5020</link>
      <description>&lt;P&gt;I would not think that var vs const would make a difference, but as I am not able to reproduce the problem I'd suggest going with that if it works for you. I recommend reaching out to Esri support if you are still hitting problems related to specific Android devices.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 15:40:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/invalid-viewpoint-value-in-onviewpointchanged/m-p/1325449#M5020</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2023-09-05T15:40:56Z</dc:date>
    </item>
  </channel>
</rss>

