gpt4 book ai didi

javascript - esri/dijit/Search javascript 版本 3.13 不同来源不创建建议

转载 作者:行者123 更新时间:2023-11-28 19:15:43 24 4
gpt4 key购买 nike

我正在尝试使用我自己的图层之一重现 esri/dijit/Search 教程,该教程是 ArcGIS API for JavaScript 3.13 版本中的新增内容。

Esri Sample

  <!DOCTYPE html>
<html><link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">
<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>ArcGIS API for JavaScript | Search widget with multiple sources</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.13/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">
<style>
html,
body,
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#search {
display: block;
position: absolute;
z-index: 2;
top: 20px;
left: 74px;
}
</style>


<script src="http://js.arcgis.com/3.13/"></script>
<script>
require([
"esri/map", "esri/dijit/Search", "esri/layers/FeatureLayer", "esri/InfoTemplate", "esri/SpatialReference", "esri/geometry/Extent", "dojo/domReady!"
], function (Map, Search, FeatureLayer, InfoTemplate, SpatialReference, Extent) {
var map = new Map("map", {
basemap: "gray",
center: [-97, 38], // lon, lat
zoom: 5
});

var s = new Search({
enableButtonMode: true, //this enables the search widget to display as a single button
enableLabel: false,
enableInfoWindow: true,
showInfoWindowOnSelect: false,
map: map
}, "search");

var sources = [];

sources.push({
featureLayer: new FeatureLayer("http://maps.eastriding.gov.uk/arcgis/rest/services/GISIntranet/MapServer/0"),
searchFields: ["ADDRESS_WITHOUT_BREAKS"],
displayField: "ADDRESS_WITHOUT_BREAKS",
exactMatch: false,
name: "ADDRESS_WITHOUT_BREAKS",
outFields: ["*"],
placeholder: "ADDRESS_WITHOUT_BREAKS",
maxResults: 6,
maxSuggestions: 6,

enableSuggestions: true,
minCharacters: 0
});

//Set the sources above to the search widget
s.set("sources", sources);

s.startup();

});
</script>
</head>

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

</html>

如果是的话,我正在考虑建议部分。如果我使用默认源,那就没问题了。我将在文本框中输入前几个字符,它将产生一些我可以选择的建议。当我使用自己的来源(如上所述)时,不会出现任何建议。我检查过错误,没有错误。我还在我的开发工具中检查了网络,建议部分没有像默认源那样触发查询。

我想知道我是否需要在我的图层上进行一些特殊设置,还是应该可以正常工作

谢谢

最佳答案

来自 API 文档

Working with suggestions is only available if working with a 10.3 geocoding service that has the suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true.

查看您的服务器,您正在运行 10.2.2,因此您需要迁移到 10.3,并确保您允许服务分页才能获得此功能。

关于javascript - esri/dijit/Search javascript 版本 3.13 不同来源不创建建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29894043/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com