ArcGIS Server 开发实践之【Search类】
开发中整理的。不足之处还请谅解! -----------------------------------------------
Class:Search 调用方式:require(["esri/dijit/Search",function(Search){......}]); /*描述:搜索小工具提供一种基于位置服务和地图、要素服务图层的搜索。这些指定的数据源在搜索框中搜索的内容。
如果用定位或地理服务时使用 findAddressCandidates方法。
搜索工具类似地理编辑工具。主要的不同时搜索工具提供附加的允许搜索和建议多种数据的功能。
注意:当使用一个空间参考的地图或其他的web墨卡托或者地理,要确保建立一个默认集合服务。
这将确保用户的位置返回相同的空间参考地图。*/
----------------------
requrie(["esri/config"],function(esriConfig){
esriConfig.defaults.geometryService="http://www.example.com/arcgis/rest/services/Utilities/Geometry/GeometryServer";
});
----------------------
构造函数:
new Search(options,srcNode) //使用给定DOM节点新建一个搜索工具
---------------------------------------
CSS Name 描述
active 类用于描述的风格活跃的“搜索”按钮,生成的菜单项。
arcgisSearch 代表节点搜索的实例小部件呈现。这是默认主题独特风格的小部件。
hasButtonMode 类指示是否显示模式按钮
hasMultipleSources 类指示是否正在使用多个来源
menuHeader 类用于样式标题搜索结果的顶部菜单。
moreResults 类用于指示是否显示额外的结果在生成的搜索弹出。
noResultsBody Class used to style the body of how "No results" is displayed.类用于样式的身体如何显示“没有结果”。
noResultsHeader Class used to style the header of how "No results" displays.类用于样式的标题显示“没有结果”。
noResultsMenu Class used to style the menu if there are "No results".类用于样式菜单如果有“没有结果”。
noResultsText The class used to style the "No results" text.类用于风格“没有结果”文本。
noValueIcon This class is used used if wanting to display a warning icon when no value is entered into the search box.使用这个类使用时如果想显示一个警告图标没有值输入到搜索框。
noValueText Class used to style the resulting dialog when no value is entered in the search box.类用于样式结果对话框时不搜索框中输入的值。
popupHeader Class used to style the popupHeader in the search popup's "More results".
resultsList Class used to style the popup's search results list.
searchAnimate Class used to style how the search animation displays.
searchBtn Class used to style the Search button.
searchButtonText The class used to style how the "Search" button displays its text.
searchClear The class used to style the "Clear search" (x) area of the widget.
searchClearFloat Used to clear floats in the Search widget.
searchClearIcon | esriIconCancel Class used to style the clear icon.
searchCollapsed Class used to indicate whether the search is collapsed.
searchExpandContainer Containing class for when the widget is expanded.
searchExpanded Class used to indicate whether the search is expanded.
searchGroup Class used to style the elements used for the input text and search.
searchIcon | esriIconZoom Class used to style the search icon.
.arcgisSearch .searchIcon {
color:orange;
font-size:20px;
}
searchInput Class used to style the search input box.
searchInputGroup Class used to style the grouping of input elements.
searchLoading Class used to indicate that the search is loading.
searchMenu Class used to style the resulting search results menu.
searchSubmit Class used to style the Search's submit button when collapsed.
searchToggle Class used to style how the toggle button displays.
searchToggleIcon | esriIconDownDir Class used to style the toggle icon.
.arcgisSearch .esriIconDownDir{
color: #ccc;
}
showMoreResults Class used to indicate if showing more results in the search result popup.
showNoResults Class indicating whether to display "No results".
showSources Class indicating whether to display sources.
showSuggestions Class indicating whether to show suggestions for text input.
sourceName Class used to style how the source name is displayed.
sourcesMenu Class used to style the drop-down menu listing all available sources.
suggestionsMenu Class used to style the drop-down menu for suggestions.
-------------------------------------------------------------------------------------------------------------------------- 属性
name type Summary
activeSourse object 只读属性的当前选中的源对象
activeSourseIndex Number 当前选择的来源
addLayersFromMap Boolean 指示是否自动添加层从地图上的所有功能。
allPlaceholder String 这个默认的值用来在搜索多个值时提示输入文本信息
autoNavigate Boolean 指示是否自动导航到所选择的结果。
autoSelect Boolean Indicates whether to automatically select the first geocoded result.
defaultSource Object (Read-only), the default source used for the Search widget.
enableButtonMode Boolean Indicates whether to enable an option to collapse/expand the search into a button.
enableHighlight Boolean Show the selected feature on the map using a default symbol determined by the source's geometry type.
enableInfoWindow Boolean Indicates whether to display the infoWindow on feature click.
enableLabel Boolean Indicates whether to enable showing a label for the geometry.
enableSearchingAll Boolean Indicates whether to display the option to search "All" sources.
enableSourcesMenu Boolean Indicates whether to enable the menu for selecting different sources.
enableSuggestions Boolean Enable suggestions for the widget.
enableSuggestionsMenu Boolean Indicates whether to display suggest results.
expanded Boolean Indicates whether to set the state of the enableButtonMode to expanded (true) or collapsed (false).
graphicsLayer Layer This is the specified graphicsLayer to use for the highlightGraphic and labelGraphic instead of map.graphics.
highlightGraphic Graphic Read-only property indicating the highlighted location graphic.
infoTemplate InfoTemplate A customized infoTemplate for the selected feature.
labelGraphic Graphic Read-only graphic property for the text label.
labelSymbol TextSymbol The text symbol for the label graphic.
loaded Boolean Read-only property indicating whether the widget is loaded.
locationToAddressDistance Number The default distance specified in meters used to reverse geocode (if not specified by source).
map Map Reference to the map.
maxResults Number The default maximum number of results returned by the widget if not specified by source.
maxSuggestions Number The default maximum number of suggestions returned by the widget if not specified by source.
minCharacters Number The default minimum number of characters needed for the search if not specified by source.
searchResults Object[] Read-only property that returns an array of current results from the search.
showInfoWindowOnSelect Boolean Indicates whether to show the infoWindow when a result is selected.
sources Object[] An array of source objects used to find search results.
suggestResults Object[] Read-only property that returns an array of current results from the suggest.
suggestionDelay Number The millisecond delay after keyup and before making a suggest network request.
theme String The CSS class selector used to uniquely style the widget.
value String The current value of the search box input text string.
visible Boolean Indicate whether to show the widget.
zoomScale Number If the result does not have an associated extent, specify this number to use as the zoom scale for the result.
---------------------------------------------------------------------
------------------------------------------------------------------------
方法:
Name 返回类型 简述
blur() None 滑动块工具的文本输入
clear() None 清除当前的值,搜索结果,显示结果,几何图形或者几何图层
collaspe() None 从按钮模式关闭小部件
destory() None 清除搜索小部件
expand() None 从按钮模式打开小部件
get(name) Object|B 从搜索小部件获取属性的值。
hide() None 隐藏搜索部件
search(value?) Promise 根据指定的来源,search()查询功能层(s)和/或执行地址匹配使用Locator(s),并返回指定任何任何适用的结果。
select(value) None 选择一个结果
set(name,value) None 设置一个非只读属性值的部件
show() 显示部件
startup() 结束搜索的小部件
suggest(value?) Promise 执行一个活动定位器上的suggest()请求或功能层。 ===================================================================
事件 blur Fired when the widget's text input loses focus.
clear-search Fired when a result is cleared from the input box or a new result is selected.
focus Fired when the widget's text input sets focus.
load Fired when the search widget has fully loaded.
search-results
{
activeSourceIndex: <Number>,
errors: <Error[]>,
numErrors: <Number>,
numResults: <Number>,
results: <Object[]>,
value: <String>
}
Fires when the search method is called and returns its results.
select-result
{
result: <Object>,
source: <Object>,
sourceIndex: <Number>
}
Fired when a search result is selected.
suggest-results
{
activeSourceIndex: <Number>,
errors: <Error[]>,
numErrors: <Number>,
numResults: <Number>,
results: <Object[]>,
value: <String>
}
Fired when the suggest method is called and returns its results.
Constructor Details
new Search(options, srcNode)
Create a new Search widget using the given DOM node.
Parameters:
<Object> options Required Set of options used to specify Search options. This parameter is required but can be null or an empty object. See the options properties below for details.
<Node | String> srcNode Required Reference or id of the HTML element where the widget should be rendered.
options properties:
<Number | String> activeSourceIndex Optional The currently selected source. The default is "all".
<Boolean> addLayersFromMap Optional Indicates whether to automatically add all the feature layers from the map. The default value is false.
<String> allPlaceholder Optional This is the default value used as a hint for input text when searching on multiple sources. The default value is "Find address or place".
<Boolean> autoNavigate Optional Indicates whether to automatically navigate to the selected result. The default value is true.
<Boolean> autoSelect Optional Indicates whether to automatically select the first geocoded result (not the first suggestion). The default value is true.
<Boolean> enableButtonMode Optional Indicates whether to enable an option to collapse/expand the search into a button. The default value is false.
<Boolean> enableHighlight Optional Indicates whether to show the selected feature on the map using the highlight symbol property. The default value is true.
<Boolean> enableInfoWindow Optional Indicates whether to display the infoWindow on feature click. The default value is true. See the enableInfoWindow property for additional information on this.
<Boolean> enableLabel Optional Indicates whether to enable showing a label for the geometry.The default value is false.
<Boolean> enableSearchingAll Optional Indicates whether to display the option to search "All" sources. Default is true.
<Boolean> enableSourcesMenu Optional Indicates whether to enable the menu for selecting different sources. The default value is true.
<Boolean> enableSuggestions Optional Indicates whether or not to enable suggest on the widget. The default value is true.
NOTE: This is available if working with a 10.3 geocoding service that has suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true.
<Boolean> enableSuggestionsMenu Optional Indicates whether to display suggest results. The default value is true.
<Boolean> expanded Optional Indicates whether to set the state of the enableButtonMode to expanded (true) or collapsed (false). The default value is false.
<Layer> graphicsLayer Optional This the specified graphicsLayer to use for the highlightGraphic and labelGraphic instead of map.graphics.
<Symbol> highlightSymbol Optional The symbol used for highlightGraphic. Defaults to PictureMarkerSymbol.
<InfoTemplate> infoTemplate Optional A customized infoTemplate for the selected feature.
NOTE: Do not specify a wildcard "${*}" for this specific infoTemplate as it will return all fields in addition to search-specific fields. <TextSymbol> labelSymbol Optional The text symbol for the label graphic.
<Number> locationToAddressDistance Optional The default distance specified in meters used to reverse geocode, (if not specified by source). The default value is 1500.
<Map> map Optional Reference to the map. If no map is specified, the value is null.
<Number> maxResults Optional The default maximum number of results returned by the widget if not specified by source. The default value is 6.
<Number> maxSuggestions Optional The default maximum number of suggestions returned by the widget if not specified by source. The default value is 6. NOTE: If working with the default ArcGIS Online Geocoding service, the default remains at 5.
<Number> minCharacters Optional The default minimum amount of characters needed for the search if not specified by source. The default value is 1.
<Boolean> showInfoWindowOnSelect Optional Indicates whether to show the infoWindow when a result is selected. The default value is true. See the showInfoWindowOnSelect property for additional information on this.
<Object[]> sources Optional An array of source objects used to find search results. Refer to the sources property for additional information on this.
<Number> suggestionDelay Optional The millisecond delay after keyup and before making a suggest network request. The default value is 150.
<String> theme Optional The CSS class selector used to uniquely style the widget. The default value is arcgisSearch.
<String> value Optional Current value of the search box input text string. The default value is "".
<Boolean> visible Optional Indicates whether to show the Search widget. Default value is true.
<Number> zoomScale Optional If the result does not have an associated extent, specify this number to use as the zoom scale for the result. The default value is 1000.
================================================================================
Sample:
require([
"esri/map","esri/dijit/Search",....],function(Map,Search,....){
var map=new Map(....);
var s=new Search({
map:map
},"search");
)}; =============================================================
具体的方法简介 <object[]>sources
源对象数组用于查找搜索结果。 支持多种地理编码服务除了搜索功能层。参见下面对象规格表结构的源对象。
默认的源对象
Default sourses[]
[
{
locator:new Locator("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),
singleLineFieldName:"SingleLine",
outFields:["Addr_type"],
name:i18n.widgets.Search.main.esriLocationName,
localSearchOptions:{
minScale:300000,
maxScale:500000
},
placeholder:i18n,widget.Search.main.placeholder,
highlighSymbol:new PictureMarkerSymbol(this.basePath+"/images/search-pointer.png",36,36).setOffset(9,18)
}
]
--------------------------------------------------
具体的示例
var sourse=[
{
locator:,
singleLineFieldName:"SingleLine",
name:"Custom Geocoding Service",
localSearchOptions:{
minScale:300000,
distance:50000
},
placeholder:"Search Geocoder",
maxResults:3,
maxSuggestions:6,
enableSuggestions:false,
minCharacters:0
},{
featureLayer:new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"),
searchFisds:["Name","Party"],
suggestionTemplate:"${Name},Party:${Party}",
exactMatch:false,
outFields:["*"],
name:"Senators",
lableSymbol:textSymbol,
placeholder:"Senator Nmae",
maxResults:6,
maxSuggestions:true,
minCharacters:0,
searchQuaryParams:{distance:5000},
},
{
featureLayer:new FeatureLayer(),{
outFields:["*"]
});
placeholder:"esri",
name:"A FeatureLayer",
prefix:"",
suffix:"",
maxResults:1,
maxSuggestions:6,
searchExtent:null,
exactMath:fasle,
searchFields:[],//默认为 FeatureLayer.displayField
displayField:"",//默认为 FeatureLayer.displayField
labelSymbol:new TextSymbol(),
minCharacters:0
}
];
===========================================
设置源的一些方法
1. Set source(s) on creation var s=new Search({
sources:[]
});
s.startup();
2.Add to sources var s=new Search();
var sources=s.get("sources");
sources.push({//new sources}) ;
s.set("sources",sources);
s.startup();
3.set sources var s=new Search();
var sources=[my sources];
s.set("sources",sources);
s.startup();
-----------------------------------------------------------
规范:
1、local Search Options
distance //指定一个搜索位置的距离,默认值为12000
minScale //位置搜索时指定比例尺至小于指定值。默认为15000 2.sources autoNavigate //同时适用于定位器和功能层。这表明是否自动导航到选定的结果一旦选中。默认是正确的。
categories //一个字符串数组限制到一个或多个类别的结果。例如“密集的地方”或“机场”。只适用于当使用世界地理编码服务。查看世界地理编码服务文档了解更多信息。
countryCode //只用于使用定位器的来源。这个会对搜索结果到指定的国家代码。例如,“US”美国和瑞典“SE”。只适用于世界地理服务。
displayField //只适用于要素图层源。结果显示正在使用的字段。默认的显示图层的第一个字段。
enableHighlight //同时适用于定位器和功能层。这表明是否在地图上显示一个图形使用highlightSymbol选中的源。默认值是正确的。
enableInfoWindow //同时适用于定位器和功能层。它显示一个信息窗口,单击选择的结果。默认是正确的。
enableLabel //同时适用于定位器和功能层。这表明是否在地图上显示一个文本标签使用labelSymbol选中的源。默认值是错误的。
enableSuggestions//同时适用于定位器和功能层。这表明是否启用建议小部件的用户输入。默认值是正确的。 注意:这是可用的,如果使用10.3地理编码服务,建议功能层,支持分页加载或10.3特性,即supportsPagination = true。
exactMathch //只适用于功能层源。这只搜索值完全匹配的返回结果。默认是假的。
featureLayer //这只适用于地图服务功能层。功能层是在搜索查询。如果搜索功能层,这是必需的。
infoTemplate //用于选择结果。同时适用于定位和功能层。
labelSymbol //TextSymbol用于标签所选择的结果。这同时适用于定位器和功能层。
localSearchOptions//只适用于在使用定位器的来源。这是用于设置为当地的距离和minScale搜索来源。有关详细信息,请参阅下面的localSearchOptions表。
locationToAddressDistance//默认的距离米为反向地理编码。
locator //这只适用于定位器的来源。这是用于搜索定位任务。这是必需的,默认为世界地理编码服务。
maxResualts //同时适用于定位器和功能层。这个数字显示返回结果的最大数目。默认值是6。
maxSuggestions //同时适用于定位器和功能层。这个数字表示建议的最大数量换取小部件的输入。默认值为15。
minCharacters //同时适用于定位器和功能层。这个数字显示所需的最小字符数在查询一个建议。默认值是1。
name //同时适用于定位器和功能层。这是来源显示的名称。
outFields //这个字符串数组同时适用于定位器和功能层。它指定的字段返回搜索结果。
placeholder //同时适用于定位器和功能层。这是用来提示源输入文本。不支持的IE9和下面。
prefix //同时适用于定位器和功能层。指定该前缀的输入搜索文本。
searchExtent //程度上对象的数组,同时适用于定位器和功能层。设置这个如果要限制搜索结果在某种程度上
searchFields //只适用于功能层。它是一个字符串值数组搜索结果在这些领域的功能层
searchQueryParams//定义了一个查询的默认选项,当搜索功能层。有些选项可能会覆盖搜索部件包括以下几点:
outSpatialReference
returnGeometry
num
outFields
where
maxAllowableOffset
objectIds
suggestionTemplate //一个模板字符串用于显示多个字段顺序定义。这仅适用于功能层和优先于displayField来源。
useMapExtent //指示是否限制搜索结果在地图的程度上。
zoomScale //适用于指定的源。如果结果没有一个关联的程度,指定要使用这个号码的缩放尺度结果。
ArcGIS Server 开发实践之【Search类】的更多相关文章
- ArcGIS Server开发实践之【Search Widget工具查询本地地图服务】
加载本地地图服务,并实现要素的查询.(不足之处还请指点)具体代码如下: <!DOCTYPE html> <html dir="ltr"> <head& ...
- ArcGIS server 开发实践之【FeatureLayer类】
全是干活,你值得拥有 要素图层类简介:Class:FeatureLayer //调用方式:require(["esri/layers/FeatureLayer"],function ...
- 【ArcGIS Server 开发系列】Flyingis六大系列讲座精品PDF奉献
转自:http://www.cnblogs.com/gispeng/archive/2008/07/24/1250116.html [ArcGIS Server 开发系列]Flyingis六大系列讲座 ...
- ArcGIS Server开发教程系列(3)切片
切片工作,我们可以一级一级的切,也可以,所有的一块切,Recreate All Tiles这项是说,在没有进行任何的切片工作时,可以选用这项:Recreate Empty Tiles这项是说,如果之前 ...
- ArcGIS Server开发教程系列(1) Arcgis server 10.1 的安装
本系列所使用的软件版本如下: Windows 7 X64 / Windows server 2008 X64 Arcgis for Desktop 10.1 Arcgis 10.1 for serve ...
- ArcGIS Server开发教程系列(2)配置ARCMAP和ARCCatalog发布服务
1. Arc catalog的配置 打开catalog,如图新增刚刚创建的server 1. Use GIS services: 用户身份连接 使用此种连接,可以浏览.使用站点内发布的所有 ...
- ArcGIS Server开发教程系列(7)使用ArcGIS API for Javascript-Hello World
ArcGIS API for Javascript API下载地址:http://support.esrichina-bj.cn/2011/0223/960.html 选择最新的下载就好了,目前是3 ...
- ArcGIS Server 开发之鹰眼地图的实现
鹰眼简单点说就是地图的联动,鹰眼的全称是OverviewMap,在ERSI提供的API包中,在dijit中进行类的调用.查了很多的资料,总结一下: 具体的代码: <!DOCTYPE html&g ...
- ArcGIS Server开发教程系列(8)ArcGIS API for Javascript-控件(小部件)
1. 鹰眼 OverviewMap小部件用于在其关联的主地图内较清楚的当前鸟瞰图的范围.当主地图范围变化时,鹰眼图会自动在其空间内更新范围以保持和地图的当前范围保持一致,当鹰眼图空间的地图范围 ...
随机推荐
- php优点
PHP,一个嵌套的缩写名称,是英文超级文本预处理语言(PHP:Hypertext Preprocessor)的缩写.PHP 是一种 HTML 内嵌式的语言,是一种在服务器端执行的嵌入HTML文档的脚本 ...
- IO流-ZIP文档
java中通常使用ZipInputStream来读ZIP文档 ZIP文档(通常)以压缩格式存储了一个或多个文件,每个ZIP文档都有一个包含诸如文件 名字和所使用的压缩方法等信息的头.在Java中,可以 ...
- 使用SQL Server作业设置定时任务
1.开启SQL Server Agent服务 使用作业需要SQL Agent服务的支持,并且需要设置为自动启动,否则你的作业不会被执行. 以下步骤开启服务:开始-->>>运行--&g ...
- java设计模式(二)---工厂方法模式
2普通工厂方法模式 就是建立一个工厂类,对实现了同一接口的一些类进行实例的创建. 2.1创建接口 /** * 发送接口 * Created by mrf on 2016/2/25. */ public ...
- java中String的相等比较
首先贴出测试用例: package test; import org.junit.Test; /** * Created by Administrator on 2015/9/16. * */ pub ...
- 20款精致的长阴影 LOGO 设计【附免费生成工具】
长阴影(Long Shadow)概念来自于最新非常流行的扁平化设计(Flat Design).扁平化设计趋势影响最大的是用户界面元素和图标,但它也开始蔓延到其他网页设计的其他部分. 长阴影其实就是扩展 ...
- SQL Server存储(6/8) :理解DCM页
我们已经讨论了各种不同的页,包括数据页.GAM与SGAM页.PFS页,还有IAM页.今天我们来看下差异变更页(Differential Change Map:DCM ),还有差异备份(differen ...
- 第1/24周 SQL Server 如何执行一个查询
大家好,欢迎来到第1周的SQL Server性能调优培训.在我们进入SQL Server性能调优里枯燥难懂的细节内容之前,我想通过讲解SQL Server如何执行一个查询来建立基础.这个部分非常重要, ...
- Entity Framework想说爱你不容易,这么多的报错,这么多的限制,该如何解决?
首先看一下采用MODEL FIRST的方式设计的实体模型对象关系图: 注意:EntityOne中有导航属性:EntityTwo 在如下代码中的几种情况进行新增操作,均会报错,新增都不会成功: stat ...
- 阅读《LEARNING HARD C#学习笔记》知识点总结与摘要系列文章索引
从发表第一篇文章到最后一篇文章,时间间隔有整整一个月,虽只有5篇文章,但每一篇文章都是我吸收<LEARNING HARD C#学习笔记>这本书的内容要点及网上各位大牛们的经验,没有半点废话 ...