如何在Arcgis javascript中将本地数据添加到popupTemplate?

时间:2019-09-06 14:39:43

标签: javascript html typescript arcgis-js-api

我想将drone.latitude,drone.longitude和track添加到fieldName,但是我找不到一种方法。到目前为止,这是我尝试过的方法,但是没有显示出来。

请给我一些帮助,因为我已经尝试了许多不同的方法来做到这一点。我是arcgis和javascript的新手,所以请耐心等待。这只是我的一部分代码,我希望它足以理解我的问题。

谢谢大家!

top.drawDrones = function() {

  //console.log("Drawing " + Object.keys(top.drones).length + " drones" );
  view.graphics.removeAll();
  dataObject.dataPoints.splice(0, dataObject.dataPoints.length);
  customMarkers.splice(0, customMarkers.length)
  //console.log(customMarkers.length)

  for (const [drone_name, drone_list] of Object.entries(top.drones)) {

    const drone = drone_list[drone_list.length-1];
    const track = drone.track
    let trackstr: string= "track"
    const X_zoom = drone.X_zoom
    const Y_zoom = drone.Y_zoom
    const Z_zoom = drone.altitude
    const Flarm_name = drone.name
    const diretion = drone.diretion
    const point = new Point({
      x: drone.longitude,
      y: drone.latitude,
    });

    // Draw line


    if (drone_list.length > 0) {

      var drone_path = []
      var i:number; 
      for(i=0; i<drone_list.length; i++) {

        const position = drone_list[i];

        drone_path.push([position.longitude, position.latitude])
      }
      drone_path=drone_path.slice(-100)
      var polyline = new Polyline({
        hasZ: false,
        hasM: true,
        paths : drone_path,
        spatialReference: { wkid: 4326 }
      }); 
      var template = new PopupTemplate({
        title: drone_name,
        content: [
          {
            type: "fields",
            fieldInfos: [
              {
                fieldName: track,
                visible: true,
                label: "Track",
                format: {
                  digitSeparator: true,
                  places: 0,
                  type: "oid"
                }
              }

            ]
          }
        ]
    });

0 个答案:

没有答案