Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <title> Trip playback</title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/css/main.css">
    <script src="https://js.arcgis.com/4.16/"></script>

    <style>
        html,
        body,
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }

        #optionsDiv {
            position: absolute;
            bottom: 17px;
            width: 100%;
            padding: 20px 0;
            z-index: 1;
            text-align: center;
        }

        button {
            background: white;
            padding: 7px;
            border: 1px solid #005e95;
            font-size: 0.9em;
            margin: 5px;
            color: #005e95;
            font-family: "Avenir Next W01", "Arial", sans-serif;
        }

        button:hover {
            background: #005e95;
            color: white;
            cursor: pointer;
        }

    </style></head>

<body>
    <div id="optionsDiv">
        <button id="addRemoveBtn"> Trip playback</button>
    </div>
    <div id="viewDiv"></div>
</body>
              
            
!

CSS

              
                
              
            
!

JS

              
                require([
  "esri/Map",
  "esri/views/SceneView",
  "esri/Graphic",
  "esri/layers/GraphicsLayer",
  "esri/geometry/Point",
  "esri/geometry/support/geodesicUtils",
  "esri/symbols/SimpleMarkerSymbol",
  "esri/symbols/PointSymbol3D",
  "esri/symbols/ObjectSymbol3DLayer"  
], function(EsriMap, SceneView, Graphic, GraphicsLayer, 
            Point, geodesicUtils,
            SimpleMarkerSymbol,PointSymbol3D, ObjectSymbol3DLayer) {            


  var myData = JSON.parse('[ { "id": 1, "heading": 131, "roll": -16, "tilt": 10, "Longitude": 76.079746685606, "Latitude": 11.0418246922348 }, { "id": 2, "heading": 131, "roll": -30, "tilt": 0, "Longitude": 76.0797786458333, "Latitude": 11.0418341619318 }, { "id": 3, "heading": 131, "roll": -32, "tilt": -14, "Longitude": 76.0798126775567, "Latitude": 11.0418454071969 }, { "id": 4, "heading": 131, "roll": -23, "tilt": -6, "Longitude": 76.0798416785037, "Latitude": 11.0418593158144 }, { "id": 5, "heading": 131, "roll": -17, "tilt": -4, "Longitude": 76.0798745265151, "Latitude": 11.0418723366477 }, { "id": 6, "heading": 131, "roll": 17, "tilt": 3, "Longitude": 76.0799085582386, "Latitude": 11.0418871330492 }, { "id": 7, "heading": 131, "roll": 20, "tilt": 4, "Longitude": 76.0799387428977, "Latitude": 11.0419013375947 } ]');
    
  const calculateAngleBetweenPoints = (point1, point2) => {    
    return geodesicUtils.geodesicDistance(
      new Point(point1.Longitude,point1.Latitude),
      new Point(point2.Longitude,point2.Latitude),'meters').azimuth;
  };

  let pntIndex = 0
  const getNextPointInfo = () => {                
    const data = myData[pntIndex];        

    const point = new Point(data.Longitude, data.Latitude);
    const heading = (pntIndex > 0) 
      ? calculateAngleBetweenPoints(myData[pntIndex-1], data)
      : data.heading;

    if(++pntIndex >= myData.length) {pntIndex = 0};            

    return { point: point, heading: heading , data: data};
  };   

  const firstPointInfo = getNextPointInfo();

  const view = new SceneView({
    container: "viewDiv",
    zoom: 5,
    map: new EsriMap({
      basemap: "satellite"
    }),
    camera: {
      position: {
        x: firstPointInfo.point.x,
        y: firstPointInfo.point.y,
        z: 4
      },
      tilt: 80,
      heading: 73
    }
  });                 

  const symbol = new PointSymbol3D({
    symbolLayers: [
      new ObjectSymbol3DLayer({
        anchor: "origin",
        depth: 8,
        height: 5,
        resource: {
          href: "https://static.arcgis.com/arcgis/styleItems/RealisticTransportation/web/resource/Dumptruck.json"
        },
        width: 7,
        heading: 73,
        tilt: 0
      })]
  });

  const pointGraphic = new Graphic(firstPointInfo.point, symbol);
  const vehicleLayer = new GraphicsLayer({graphics:[pointGraphic]});          
  view.map.add(vehicleLayer);

  view.goTo({
    target: pointGraphic,
    scale: 100,
    tilt: 80
  });

  let playing = false;
  let timeoutHandle;
  let nextPointInfo;
  const goToNextPoint = ()=>{
    nextPointInfo = getNextPointInfo();
    if(nextPointInfo){
      // UPDATE GEOMETRY //
      pointGraphic.geometry = nextPointInfo.point;

      // GET SYMBOL //
      const pointSymbol = pointGraphic.symbol.clone();      
      const symbolLayer = pointSymbol.symbolLayers.getItemAt(0);
      symbolLayer.heading = nextPointInfo.heading;
      symbolLayer.roll = nextPointInfo.data.roll;
      symbolLayer.tilt = nextPointInfo.data.tilt;                 
      pointSymbol.symbolLayers = [symbolLayer];      
      // UPDATE SYMBOL //
      pointGraphic.symbol = pointSymbol;            

      if(playing){
        timeoutHandle = setTimeout(goToNextPoint, 1000);
      }
    }
  };  
  
  document.getElementById('addRemoveBtn').addEventListener('click', () => {    
    playing = (!playing);    
    if(playing){
      goToNextPoint();
    } else {
      clearTimeout(timeoutHandle);
    }
    console.info("Playing:", playing);
  }, false);
          
});
              
            
!
999px

Console