Display attribute value from arcgis layer to html textbox

一笑奈何 提交于 2020-01-07 09:43:35

问题


I want to display attribute value from arcgis layer to html input textbox using javascript

Can anyone help me on this issue?
Best Regards.


回答1:


Just click on a tree, it will fill the inputText on the top right corner

<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.19/esri/css/esri.css">
<style>
  html, body, #mapDiv {
    height: 100%;
    padding: 0;
    margin: 0;
  }
  #inputAttribute {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 300px;
  }
</style>

<script>var dojoConfig = { parseOnLoad:true };</script>
<script src="https://js.arcgis.com/3.19compact/"></script>
<script>
  require(["esri/map", "esri/layers/FeatureLayer", "dojo/on", "dojo/dom", "dojo/domReady!"], function(Map, FeatureLayer, On, Dom) {
    var node = Dom.byId('inputAttribute');
    var map = new Map("mapDiv", {
      center: [-122.41, 37.78],
      zoom: 17,
      basemap: "topo"
    });
    var featureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Street_Trees/FeatureServer/0",{
      outFields: ["qSpecies"]
    });
    map.addLayer(featureLayer);
    On(featureLayer, 'click', function (e) {
      node.value = e.graphic.attributes.qSpecies;
    });
  });
</script>
<div id="mapDiv"></div>
<input type="text" name="attribut" id="inputAttribute">


来源:https://stackoverflow.com/questions/42062363/display-attribute-value-from-arcgis-layer-to-html-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!