<?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: Labels and markers created but not updating. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labels-and-markers-created-but-not-updating/m-p/1357185#M83026</link>
    <description>&lt;P&gt;It doesn't appear there's a documented way to make the View update when a geometry's coordinates have changed, apart from cloning the geometry or the graphic.&lt;/P&gt;&lt;P&gt;Probably the best alternate way to achieve this is to use the undocumented "notifyGeometryChanged" method of the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html" target="_self"&gt;Graphic&lt;/A&gt; class.&amp;nbsp; For example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;graphic.geometry.latitude = newLat;
graphic.geometry.longitude = newLon;
graphic.notifyGeometryChanged();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you go in this direction, you'd need to change your "pointsBySerialNumber" map to store references to the graphic objects instead of the point objects.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Dec 2023 00:11:18 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2023-12-06T00:11:18Z</dc:date>
    <item>
      <title>Labels and markers created but not updating.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labels-and-markers-created-but-not-updating/m-p/1356677#M83008</link>
      <description>&lt;P&gt;The code creates the marker for each SN but the marker and labels do not move after the initial creation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      client.on('message', (topic, message) =&amp;gt; {
        const payload = JSON.parse(message.toString());
        console.log('Received message:');

        const serialNumber = payload.serial_number;

        // Check if a point already exists for this serial number
        if (pointsBySerialNumber.hasOwnProperty(serialNumber)) {
          // Update the existing point's location
          const existingPoint = pointsBySerialNumber[serialNumber];
          existingPoint.latitude = payload.latitude;
          existingPoint.longitude = payload.longitude;
          existingPoint.z = payload.elevation_agl;
          console.log(existingPoint);
          // Update the existing label's location
          existingPoint.label.geometry = existingPoint.geometry.clone();
        } 
// The else works 
        else {
          // Create a new point and store it in the dictionary
          const newPoint = new Point({
            latitude: payload.latitude,
            longitude: payload.longitude,
            z: payload.elevation_agl,
            spatialReference: {
              wkid: 4326
            }
          });
          const newLabel = new Point({
            latitude: payload.latitude,
            longitude: payload.longitude,
            z: payload.elevation_agl + 50,
            spatialReference: {
              wkid: 4326
            }
          });

// Lets update the label and AGL using the Last 4 of the SN
          let lab = serialNumber.slice(-4) + ' \n AGL:' + Math.floor(payload.height).toString();

          const label = new Graphic({
            geometry: newLabel,
            symbol: {
              type: "text",
              color: [255, 255, 255],
              haloColor: [0, 0, 0],
              haloSize: 2,
              text: lab,
              font: {
                size: 12,
                family: "sans-serif"
              }
            }
          });

          const imageUrl = 'p.png'; // Replace with the URL of your image
          const imageSymbol = {
            type: 'picture-marker',
            url: imageUrl,
            width: 20, // Adjust the width of the image
            height: 20, // Adjust the height of the image
            yoffset: 25 // Adjust this value to set the desired vertical offset
          };

          // Add the new image and label to the map
          view.graphics.addMany([
            new Graphic({
              geometry: newPoint,
              symbol: imageSymbol
            }),
            label
          ]);

          // Store the new point and label in the dictionary
          pointsBySerialNumber[serialNumber] = {
            geometry: newPoint,
            label: label
          };
        }
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 04:01:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labels-and-markers-created-but-not-updating/m-p/1356677#M83008</guid>
      <dc:creator>john432003</dc:creator>
      <dc:date>2023-12-05T04:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Labels and markers created but not updating.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labels-and-markers-created-but-not-updating/m-p/1357185#M83026</link>
      <description>&lt;P&gt;It doesn't appear there's a documented way to make the View update when a geometry's coordinates have changed, apart from cloning the geometry or the graphic.&lt;/P&gt;&lt;P&gt;Probably the best alternate way to achieve this is to use the undocumented "notifyGeometryChanged" method of the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html" target="_self"&gt;Graphic&lt;/A&gt; class.&amp;nbsp; For example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;graphic.geometry.latitude = newLat;
graphic.geometry.longitude = newLon;
graphic.notifyGeometryChanged();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you go in this direction, you'd need to change your "pointsBySerialNumber" map to store references to the graphic objects instead of the point objects.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 00:11:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labels-and-markers-created-but-not-updating/m-p/1357185#M83026</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-12-06T00:11:18Z</dc:date>
    </item>
  </channel>
</rss>

