簡體   English   中英

Dojo FilteringSelect顯示為純文本框

[英]Dojo FilteringSelect shows up as plain text box

我剛剛開始嘗試將Dojo與ESRI ArcGIS Server一起使用。 我嘗試了一些教程,但Dojo FilteringSelect Dijit遇到了問題。

我的代碼的相關部分:

<script>
  dojo.require("esri.map");
  dojo.require("esri.tasks.query");
  dojo.require("dojo.data.ItemFileReadStore");
  dojo.require("dijit.form.FilteringSelect");

  var map;

  function init() {
    map = new esri.Map("mapDiv",{
      basemap: "streets",
      center: [-80.94, 33.646],
      zoom: 8
    });
    dojo.connect(map, "onLoad", initFunctionality);
  }

  function initFunctionality(map) {
    //build query task
    var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");

    //build query filter
    var query = new esri.tasks.Query();
    query.returnGeometry = true;
    query.outFields = ["NAME", "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI"];
    query.where = "STATE_NAME = 'South Carolina'";
    query.outSpatialReference = {"wkid":102100};

    var infoTemplate = new esri.InfoTemplate();
    infoTemplate.setTitle("${NAME}");
    infoTemplate.setContent( "<b>2000 Population: </b>${POP2000}<br/>"
                         + "<b>2000 Population per Sq. Mi.: </b>${POP00_SQMI}<br/>"
                         + "<b>2007 Population: </b>${POP2007}<br/>"
                         + "<b>2007 Population per Sq. Mi.: </b>${POP07_SQMI}");

    map.infoWindow.resize(245,105);

    //Can listen for onComplete event to process results or can use the callback option in the queryTask.execute method.
    dojo.connect(queryTask, "onComplete", function(featureSet) {
      map.graphics.clear();

      var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.35]), 1),new dojo.Color([125,125,125,0.35]));

      //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.
      dojo.forEach(featureSet.features,function(feature){
        var graphic = feature;
        graphic.setSymbol(symbol);
        graphic.setInfoTemplate(infoTemplate);

        map.graphics.add(graphic);
      });
    });

    queryTask.execute(query);
  }

  function initLineID(features) {
    var lineIdObjects = [];
    dojo.forEach(features.features, function(feature) {
        lineIdObjects.push({"name": feature.attributes.field_name});
    });

    //Build the appropriate data object for our data component
    var data = {
          "identifier": "name",
          "items": lineIdObjects
    }

    //bind the data object to the datastore
    var lineDataStore = new dojo.data.ItemFileReadStore({data: data});

    //bind the data store to the FilteringSelect component
    dijit.byId("lineid").store = lineDataStore;
 } 

  dojo.ready(init);
</script>

以及

<input dojoType="dijit.form.FilteringSelect" 
       id="lineid"
       searchAttr="name" 
       name="widgetName" 
       onChange="doSomething(this.value)">

我面臨的挑戰是,結果頁面僅顯示基本內容

<input type="text"> 

框。 有人知道為什么嗎? 謝謝。

我的猜測是您尚未配置主題。 您可以通過添加樣式表並修改body元素來實現。

在此示例中,我使用了claro主題。

<link href="PATH_TO/dojo/resources/dojo.css" rel="stylesheet">
<link href="PATH_TO/dijit/themes/dijit.css" rel="stylesheet">
<link href="PATH_TO/dijit/themes/tundra/tundra.css" rel="stylesheet">

將主題名稱添加到body元素。

<body class="tundra">

parseOnLoad設置為false。 供我將來參考,我為什么要保留為假?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM