ArcGIS API for JavaScript——要素服务(FeatureLayer)

ArcGIS API for JavaScript——要素服务(FeatureLayer)
将FeatureLayer添加到map上的基本代码


<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Create Map and add a dynamic layertitle>
    
    <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/3.18/3.18/dijit/themes/claro/claro.css"/>
    <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/3.18/3.18/esri/css/esri.css" />
    <script src="http://localhost/arcgis_js_api/library/3.18/3.18/init.js" djConfig="parseOnLoad:true">script>
    <style>
        html, body, #map {
          padding: 0;
          margin: 0;
          height: 100%;
          width: 100%;
        }
    style>

    <script>
    require([
        "esri/map",
        "esri/layers/FeatureLayer",
        "dojo/domReady!"
      ],
      function(
        Map,
        FeatureLayer,
      ) {

        var map = new Map("map");

        /****************************************************************
         * Add feature layer - A FeatureLayer at minimum should point
         * to a URL to a feature service or point to a feature collection 
         * object.
         ***************************************************************/

        // Carbon storage of trees in Warren Wilson College.
        var featureLayer = new FeatureLayer("http://localhost:6080/arcgis/rest/services/cs/MapServer/0",{
            mode: FeatureLayer.MODE_SNAPSHOT,      //快照模式,重要
            outFields: ["*"]         //输出所有的属性字段
        });
        map.addLayer(featureLayer);

      });
    script>
    head>

    <body>
      <div id="map">div>
    body>

html>

你可能感兴趣的:(ArcGis,API,for,JavaScript)