第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將外部變量傳遞給彈出窗口中的字段:(arcgis-js-api)

將外部變量傳遞給彈出窗口中的字段:(arcgis-js-api)

德瑪西亞99 2022-10-27 15:16:54
這是我的代碼,我在其中通過一個休息調(diào)用在 arcgis-js-api (4.xx) 中設(shè)置和調(diào)用一個彈出窗口...問題我有一個外部變量我想在“放置”字段中填充這個外部變量不是來自同一個休息調(diào)用,我有這個值,不知道為什么它不會在現(xiàn)場接受它?var place = 'something cool x';........   var popuptemp = {          title: "Shake Intensity",          content: [{            type: "fields",            fieldInfos: [{                fieldName: "grid_value",                label: "Grid Value"              },              {                fieldName: "id",                label: "id"              },              {                fieldName: "place",                label: "place"              },              {                fieldName: "ObjectID",                label: "ObjectID"              },              {                fieldName: "url",                label: "Url"              }            ]          }]        }        fl = new FeatureLayer({          source: gras,          objectIdField: "ObjectID",          geometryType: "polygon",          fields: [{            name: "ObjectID",            alias: "ObjectID",            type: "oid"          }, {            name: "id",            alias: "id",            type: "string"          }, {            name: place <--------------------- tried just calling the var here with no avail, no errors, just nothing displays            alias: "place",            type: "string"          }, {            name: "url",            alias: "url",            type: "string"          }, {            name: "grid_value",            alias: "grid_value",            type: "double"          }],          renderer: renderer,          popupEnabled: true,          popupTemplate: popuptemp        });        map.add(fl);
查看完整描述

1 回答

?
ibeautiful

TA貢獻1993條經(jīng)驗 獲得超6個贊

您將無法添加字段等外部數(shù)據(jù)。但是您可以使用函數(shù)來定義內(nèi)容。看看我為你做的這個例子,其中有author全局價值。


<html>


<head>

  <meta charset="utf-8">

  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

  <title>ArcGIS API for JavaScript Hello World App</title>

  <style>

    html,

    body,

    #viewDiv {

      padding: 0;

      margin: 0;

      height: 100%;

      width: 100%;

    }

    .disclaimer {

      font-size: 14px;

      font-style: italic;

      color: white;

      background-color: black;

    }

  </style>


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

  <script src="https://js.arcgis.com/4.15/"></script>


  <script>

    require([

      'esri/Map',

      'esri/views/MapView',

      'esri/layers/FeatureLayer'

    ], function (Map, MapView, FeatureLayer) {


      let author = 'by @cabesuon';


      const map = new Map({

        basemap: 'streets-navigation-vector'

      });


      const view = new MapView({

        container: 'viewDiv',

        map: map,

        zoom: 12,

        center: {

          latitude: 32.7353,

          longitude: -117.1490

        }

      });


      function toGraphic(lon, lat, ObjectID, title, addrs, url) {

        return {

          geometry: {

            type: 'point',

            longitude: lon,

            latitude: lat

          },

          attributes: {

            ObjectID,

            title,

            addrs,

            url

          }

        }

      }

      

      const graphics = [

        toGraphic(

          -117.1560632,

          32.727482,

          1,

          'Automotive Museum',

          '2080 Pan American Plaza, San Diego, CA 92101, United States',

          'http://sdautomuseum.org/'

        ),

        toGraphic(

          -117.1763293,

          32.7136902,

          2,

          'USS Midway Museum',

          '910 N Harbor Dr, San Diego, CA 92101, United States',

          'http://www.midway.org/'

        ),

        toGraphic(

          -117.2284536,

          32.7641112,

          3,

          'SeaWorld',

          '500 Sea World Dr, San Diego, CA 92109, United States',

          'https://seaworld.com/san-diego'

        ),

        toGraphic(

          -117.1557741,

          32.7360032,

          4,

          'Zoo',

          '2920 Zoo Dr, San Diego, CA 92101, United States',

          'https://zoo.sandiegozoo.org/'

        )

      ];


      function popupContent (feature) {

        const div = document.createElement('div');

        div.innerHTML =

        `Address: ${feature.graphic.attributes.addrs}<br>` +

        `<a href='${feature.graphic.attributes.url}'>${feature.graphic.attributes.url}</a><br><br>` +

        `<span class="disclaimer">${author}</span>`;

        return div;

      }


      const layer = new FeatureLayer({

        source: graphics,

        fields: [

          {

            name: 'ObjectID',

            alias: 'ObjectID',

            type: 'oid'

          }, {

            name: 'title',

            alias: 'title',

            type: 'string'

          }, {

            name: 'addrs',

            alias: 'addrs',

            type: 'string'

          }, {

            name: 'url',

            alias: 'url',

            type: 'string'

          }

        ],

        objectIDField: ['ObjectID'],

        geometryType: 'point',

        renderer: {

          type: 'simple',

          symbol: {

            type: 'text',

            color: 'red',

            text: '\ue61d',

            font: {

              size: 30,

              family: 'CalciteWebCoreIcons'

            }

          }

        },

        popupTemplate: {

          title: '{title}',

          content: popupContent,

          outFields: ['*']

        }

      });

      

      map.add(layer);


    });

  </script>

</head>


<body>

  <div id="viewDiv"></div>

</body>


</html>


查看完整回答
反對 回復(fù) 2022-10-27
  • 1 回答
  • 0 關(guān)注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號