<?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: Arcgis Javascript 4.17 how to create a pointer to move in smooth way like google maps in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1275050#M80731</link>
    <description>&lt;P&gt;Thanks for clarifying - unfortunately I dont think there's any way to animate something in the framework without clearing and readding it - as effectively you need to redraw the frame for it to animate.&lt;BR /&gt;&lt;BR /&gt;The smoothness comes into how often you update the frame and how far you're moving the point.&lt;BR /&gt;&lt;BR /&gt;If you simply animating from one co-ordinate from another you can just calculate the steps inbetween the two endpoints and then remove and add a point to the new step.&lt;BR /&gt;&lt;BR /&gt;If it's along a route you'll need to calculate the route and likely densify the results so you have more steps to animate through.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;This is rough example based on the sample code, after you click two points on the map it draws a new symbol and clears and adds the point along the path effectively animating it.&lt;BR /&gt;&lt;BR /&gt;To get even more smooth results you'd probably increase the density and decrease the time between updates.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;!-- 

To run this demo, you need to replace 'YOUR_API_KEY' with an API key from the ArcGIS Developers dashboard.

Sign up for a free account and get an API key.

https://developers.arcgis.com/documentation/mapping-apis-and-services/get-started/

 --&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;Route | Sample | ArcGIS Maps SDK for JavaScript 4.26&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      #paneDiv {
        position: absolute;
        top: 10px;
        left: 62px;
        padding: 0 12px 0 12px;
        background-color: rgba(0, 0, 0, 0.5);
        color: white;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.26/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.26/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/Graphic",
        "esri/layers/GraphicsLayer",
        "esri/rest/route",
        "esri/rest/support/RouteParameters",
        "esri/rest/support/FeatureSet",
        "esri/geometry/geometryEngine"
      ], function (
        Map,
        MapView,
        Graphic,
        GraphicsLayer,
        route,
        RouteParameters,
        FeatureSet,
        geometryEngine
      ) {
        // Point the URL to a valid routing service
        const routeUrl =
          "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";

        // The stops and route result will be stored in this layer
        const routeLayer = new GraphicsLayer();
        const pinLayer = new GraphicsLayer();
        let routeShowing = false;
        let index = 0;
        let routeResult = null


        // Setup the route parameters
        const routeParams = new RouteParameters({
          // An authorization string used to access the routing service
          apiKey: "%YOUR_API_KEY%",
          stops: new FeatureSet(),
          outSpatialReference: {
            // autocasts as new SpatialReference()
            wkid: 3857
          }
        });

        // Define the symbology used to display the stops
        const stopSymbol = {
          type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
          style: "cross",
          size: 15,
          outline: {
            // autocasts as new SimpleLineSymbol()
            width: 4
          }
        };

        const pinSymbol = {
          type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
          style: "circle",
          size: 10,
          outline: {
            // autocasts as new SimpleLineSymbol()
            width: 6
          }
        };

        // Define the symbology used to display the route
        const routeSymbol = {
          type: "simple-line", // autocasts as SimpleLineSymbol()
          color: [0, 0, 255, 0.5],
          width: 5
        };

        const map = new Map({
          basemap: "streets-navigation-vector",
          layers: [routeLayer, pinLayer] // Add the route layer to the map
        });

        const view = new MapView({
          container: "viewDiv", // Reference to the scene div created in step 5
          map: map, // Reference to the map object created before the scene
          center: [-117.195, 34.057],
          zoom: 13
        });

        // Adds a graphic when the user clicks the map. If 2 or more points exist, route is solved.
        view.on("click", addStop);

        function addStop(event) {
          // Add a point at the location of the map click
          const stop = new Graphic({
            geometry: event.mapPoint,
            symbol: stopSymbol
          });

          routeLayer.add(stop);

          // Execute the route if 2 or more stops are input
          routeParams.stops.features.push(stop);
          if (routeParams.stops.features.length &amp;gt;= 2) {
            route.solve(routeUrl, routeParams).then(showRoute);
          }
        }
        // Adds the solved route to the map as a graphic
        function showRoute(data) {
          routeResult = data.routeResults[0].route;
          routeResult.geometry = geometryEngine.densify(routeResult.geometry, 25);
          routeResult.symbol = routeSymbol;
          routeLayer.add(routeResult);
          const pinPoint = new Graphic({
            geometry: {
             x:  routeResult.geometry.paths[0][0][0],
             y:  routeResult.geometry.paths[0][0][1],
             spatialReference: view.spatialReference,
             type: "point"
            },
            symbol: pinSymbol
          });
          pinLayer.add(pinPoint);
          routeShowing = true;

        }
        
        view.when(() =&amp;gt; {
          
          let timerControl = setInterval(() =&amp;gt; {
            if(routeShowing === true &amp;amp;&amp;amp; index &amp;lt; routeResult.geometry.paths[0].length ) {
              index++;
              pinLayer.removeAll();
              const pinPoint = new Graphic({
            geometry: {
            x:  routeResult.geometry.paths[0][index][0],
            y:  routeResult.geometry.paths[0][index][1],
            spatialReference: view.spatialReference,
            type: "point"
            },
            symbol: pinSymbol
          });
          pinLayer.add(pinPoint);
            
            }
          }, 60);
        })
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div id="paneDiv" class="esri-widget"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;
          Click on the map to add stops to the route. The route from the last
          stop to the newly added stop is calculated. If a stop is not
          reachable, then the last valid point is set as the starting point.
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2023 00:54:48 GMT</pubDate>
    <dc:creator>JamesIng</dc:creator>
    <dc:date>2023-04-04T00:54:48Z</dc:date>
    <item>
      <title>Arcgis Javascript 4.17 how to create a pointer to move in smooth way like google maps</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1273430#M80691</link>
      <description>&lt;P&gt;My goal is to move a pointer from one geo location to another based on the GPS location received from the device. however, i managed to do this by clearing the layer and re drawing the point on the map. but in a graphical prospective I need to move the pointer in a smooth way rather than clearing out the point and readding it to the maps. this application is related to fleet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be great if someone could point me on the right direction on this.&lt;/P&gt;&lt;P&gt;im using Arcgis 4.17 Javascript API&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 08:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1273430#M80691</guid>
      <dc:creator>IshamFazal</dc:creator>
      <dc:date>2023-03-30T08:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Arcgis Javascript 4.17 how to create a pointer to move in smooth way like google maps</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1273855#M80705</link>
      <description>&lt;P&gt;You can use the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo" target="_self"&gt;mapview.goTo()&lt;/A&gt; method to animate from one location to another - supplying the new GPS location as the target.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 20:47:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1273855#M80705</guid>
      <dc:creator>JamesIng</dc:creator>
      <dc:date>2023-03-30T20:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Arcgis Javascript 4.17 how to create a pointer to move in smooth way like google maps</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1274510#M80718</link>
      <description>&lt;P&gt;mapview.goTo() this method is used to navigate from 1 point to another. that's not what I am looking for. actually im looking for something like this.&lt;/P&gt;&lt;P&gt;I need the point to be moved from 1 location to another without clearing the mapview and readding the point. I need to move the point by animating it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;basically a fleet moving on the street. that's the whole goal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 04:52:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1274510#M80718</guid>
      <dc:creator>IshamFazal</dc:creator>
      <dc:date>2023-04-03T04:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcgis Javascript 4.17 how to create a pointer to move in smooth way like google maps</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1275050#M80731</link>
      <description>&lt;P&gt;Thanks for clarifying - unfortunately I dont think there's any way to animate something in the framework without clearing and readding it - as effectively you need to redraw the frame for it to animate.&lt;BR /&gt;&lt;BR /&gt;The smoothness comes into how often you update the frame and how far you're moving the point.&lt;BR /&gt;&lt;BR /&gt;If you simply animating from one co-ordinate from another you can just calculate the steps inbetween the two endpoints and then remove and add a point to the new step.&lt;BR /&gt;&lt;BR /&gt;If it's along a route you'll need to calculate the route and likely densify the results so you have more steps to animate through.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;This is rough example based on the sample code, after you click two points on the map it draws a new symbol and clears and adds the point along the path effectively animating it.&lt;BR /&gt;&lt;BR /&gt;To get even more smooth results you'd probably increase the density and decrease the time between updates.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;!-- 

To run this demo, you need to replace 'YOUR_API_KEY' with an API key from the ArcGIS Developers dashboard.

Sign up for a free account and get an API key.

https://developers.arcgis.com/documentation/mapping-apis-and-services/get-started/

 --&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;Route | Sample | ArcGIS Maps SDK for JavaScript 4.26&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      #paneDiv {
        position: absolute;
        top: 10px;
        left: 62px;
        padding: 0 12px 0 12px;
        background-color: rgba(0, 0, 0, 0.5);
        color: white;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.26/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.26/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/Graphic",
        "esri/layers/GraphicsLayer",
        "esri/rest/route",
        "esri/rest/support/RouteParameters",
        "esri/rest/support/FeatureSet",
        "esri/geometry/geometryEngine"
      ], function (
        Map,
        MapView,
        Graphic,
        GraphicsLayer,
        route,
        RouteParameters,
        FeatureSet,
        geometryEngine
      ) {
        // Point the URL to a valid routing service
        const routeUrl =
          "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";

        // The stops and route result will be stored in this layer
        const routeLayer = new GraphicsLayer();
        const pinLayer = new GraphicsLayer();
        let routeShowing = false;
        let index = 0;
        let routeResult = null


        // Setup the route parameters
        const routeParams = new RouteParameters({
          // An authorization string used to access the routing service
          apiKey: "%YOUR_API_KEY%",
          stops: new FeatureSet(),
          outSpatialReference: {
            // autocasts as new SpatialReference()
            wkid: 3857
          }
        });

        // Define the symbology used to display the stops
        const stopSymbol = {
          type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
          style: "cross",
          size: 15,
          outline: {
            // autocasts as new SimpleLineSymbol()
            width: 4
          }
        };

        const pinSymbol = {
          type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
          style: "circle",
          size: 10,
          outline: {
            // autocasts as new SimpleLineSymbol()
            width: 6
          }
        };

        // Define the symbology used to display the route
        const routeSymbol = {
          type: "simple-line", // autocasts as SimpleLineSymbol()
          color: [0, 0, 255, 0.5],
          width: 5
        };

        const map = new Map({
          basemap: "streets-navigation-vector",
          layers: [routeLayer, pinLayer] // Add the route layer to the map
        });

        const view = new MapView({
          container: "viewDiv", // Reference to the scene div created in step 5
          map: map, // Reference to the map object created before the scene
          center: [-117.195, 34.057],
          zoom: 13
        });

        // Adds a graphic when the user clicks the map. If 2 or more points exist, route is solved.
        view.on("click", addStop);

        function addStop(event) {
          // Add a point at the location of the map click
          const stop = new Graphic({
            geometry: event.mapPoint,
            symbol: stopSymbol
          });

          routeLayer.add(stop);

          // Execute the route if 2 or more stops are input
          routeParams.stops.features.push(stop);
          if (routeParams.stops.features.length &amp;gt;= 2) {
            route.solve(routeUrl, routeParams).then(showRoute);
          }
        }
        // Adds the solved route to the map as a graphic
        function showRoute(data) {
          routeResult = data.routeResults[0].route;
          routeResult.geometry = geometryEngine.densify(routeResult.geometry, 25);
          routeResult.symbol = routeSymbol;
          routeLayer.add(routeResult);
          const pinPoint = new Graphic({
            geometry: {
             x:  routeResult.geometry.paths[0][0][0],
             y:  routeResult.geometry.paths[0][0][1],
             spatialReference: view.spatialReference,
             type: "point"
            },
            symbol: pinSymbol
          });
          pinLayer.add(pinPoint);
          routeShowing = true;

        }
        
        view.when(() =&amp;gt; {
          
          let timerControl = setInterval(() =&amp;gt; {
            if(routeShowing === true &amp;amp;&amp;amp; index &amp;lt; routeResult.geometry.paths[0].length ) {
              index++;
              pinLayer.removeAll();
              const pinPoint = new Graphic({
            geometry: {
            x:  routeResult.geometry.paths[0][index][0],
            y:  routeResult.geometry.paths[0][index][1],
            spatialReference: view.spatialReference,
            type: "point"
            },
            symbol: pinSymbol
          });
          pinLayer.add(pinPoint);
            
            }
          }, 60);
        })
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div id="paneDiv" class="esri-widget"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;
          Click on the map to add stops to the route. The route from the last
          stop to the newly added stop is calculated. If a stop is not
          reachable, then the last valid point is set as the starting point.
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 00:54:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-4-17-how-to-create-a-pointer-to/m-p/1275050#M80731</guid>
      <dc:creator>JamesIng</dc:creator>
      <dc:date>2023-04-04T00:54:48Z</dc:date>
    </item>
  </channel>
</rss>

