在要素图层上设置属性

可以在要素图层上设置其他属性,以更改其绘制和行为方式。definitionExpression设置为仅绘制海拔增益小于250英尺renderer的路径,a 将路径绘制为绿色,a popupTemplate将显示路径名称和弹出窗口中的所有字段。

      // Trails feature layer (lines)
      var trailsLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
        //*** ADD ***//
        definitionExpression: "ELEV_GAIN < 250",

        //*** ADD ***//
        renderer: {
          type: "simple",
          symbol: {
            type: "simple-line",
            color: "green",
            width: "2px"
          }
        },

        //*** ADD ***//
        outFields: ["TRL_NAME","ELEV_GAIN"],

        //*** ADD ***//
        popupTemplate: {  // Enable a popup
          title: "{TRL_NAME}", // Show attribute value
          content: "The trail elevation gain is {ELEV_GAIN} ft."  // Display text in pop-up
        }
      });
posted @ 2020-01-14 17:10  恋上微笑的天使  阅读(222)  评论(0编辑  收藏  举报