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           //适用于指定的源。如果结果没有一个关联的程度,指定要使用这个号码的缩放尺度结果。
时间: 2024-08-02 07:42:03

ArcGIS Server 开发实践之【Search类】的相关文章

ArcGIS Server开发教程系列(3)切片

切片工作,我们可以一级一级的切,也可以,所有的一块切,Recreate All Tiles这项是说,在没有进行任何的切片工作时,可以选用这项:Recreate Empty Tiles这项是说,如果之前已经对某一级进行了切片,再重新切片时,可以选这项,具体可以查看帮助:Delete Tiles这项可以删除之前切的切片:比方说我们计算机正在切图,突然间断电了,切了几天,几十G的地图切片,怎么办?我们不能重新开始切啊,我们就可以选择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 server ArcSDE10.1 SQL Server VS 2010 所用数据全部存储在SDE中. Arcgis server10.1下载地址(不做永久保证): http://yun.baidu.com/s/1kTp96Rl 安装时,需要设置用户名密码,这里一定要记清楚. 设置账户为 arcgis 密码 

ArcGIS Server开发教程系列(2)配置ARCMAP和ARCCatalog发布服务

1.       Arc catalog的配置 打开catalog,如图新增刚刚创建的server 1. Use GIS services: 用户身份连接 使用此种连接,可以浏览.使用站点内发布的所有服务.但是,不能编辑服务器属性.发布服务.编辑服务属性或者添加.删除.启动.停止或暂停服务. 2. Pulish GIS services: 发布身份连接 使用此种连接,可以发布GIS服务,也可以配置和发布草案服务,但是不能编辑站点的任何属性. 3. Administrator GIS servic

ArcGIS Server 开发之鹰眼地图的实现

鹰眼简单点说就是地图的联动,鹰眼的全称是OverviewMap,在ERSI提供的API包中,在dijit中进行类的调用.查了很多的资料,总结一下: 具体的代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>鹰眼和比例尺</title>

iOS开发实践:一个类微博客户端从启动到与用户交互的过程

本文基于数据字典和数据流图两种工具讲述一个完整微博客户端的实现.数据字典和数据流图都可以用来表达线程的执行流程,同时定义了需要的类,是进一步设计类的基础. 数据字典实际上是一张表,表的第一个字段是程序代码中的标识符,其它字段具体描述它在线程中被如何使用,以及它所依赖的其它元素,数据字典中各个标识符基本上也是按照线程的执行流程来排序. 数据流图是一个平面拓扑结构,每个节点或者是外部数据,或者是可被线程执行的代码模块.从外部数据到代码模块的边意味着线程在执行代码模块的时候需要用到外部数据,从代码模块

[SOE] ArcGIS Server对象扩展(SOE)开发注意事项

ArcGIS  Server对象扩展(SOE)开发注意事项 1.SOE介绍 在ArcGIS 10.1中ArcGIS Server不在支持DCOM方式的连接,这也就意味着我们不能通过本地方式的连接使用ArcObjects提供的更多功能,所以我们推荐一种新的方式来实现这些功能,这种方式就是SOE服务器对象扩展.SOE存在于整个服务对象的生存期内,可以利用服务对象的资源并对其进行扩展.一个SOE通常在服务对象创建是初始化,并且在整个服务对象的生存期内只会被创建一次.SOE支持SOAP和REST两种访问

ArcGIS Engine开发前基础知识(1)

ArcGIS二次开发是当前gis领域的一项重要必不可少的技能.下面介绍它的基本功能 一.ArcGIS Engine功能 在使用之前首先安装和部署arcgis sdk,(在这里不在赘述相关知识)可以实现的功能主要有地图的基本操作.信息查询.专题地图制作.数据编辑.网络分析.空间统计分析.三维分析等. 1.地图的基本操作 地图的基本操作主要包括加载矢量.栅格数据,浏览缩放地图,保存地图,在地图上显示文本注记,绘制点线面几何体等. 2.信息查询 信息查询主要通过矩形圆形或多边形来选中地图上的要素,或者

ASP.NET MVC5 网站开发实践(二) Member区域 - 添加文章

转自:http://www.cnblogs.com/mzwhj/p/3592895.html 上次把架构做好了,这次做添加文章.添加文章涉及附件的上传管理及富文本编辑器的使用,早添加文章时一并实现. 要点: 富文本编辑器采用KindEditor.功能很强大,国人开发,LGPL开源,自己人的好东西没有理由不支持. 附件的上传同样基于KindEditor实现,可以上传图片,flash,影音,文件等. 目录 ASP.NET MVC5 网站开发实践 - 概述 ASP.NET MVC5 网站开发实践(一)

使用ArcGIS Server发布我们的数据

原文:使用ArcGIS Server发布我们的数据 引言 上一篇我们已经安装好了ArcGIS体系的服务软件,这一篇将介绍如何把我们自己的数据通过ArcGIS Server发布出去,并且能够通过Web页面进行显示和编辑. 发布数据服务 在进行WebGIS开发中,地图显示的内容可以分成两类:一类是底图,或者是矢量的世界地图.中国地图.某个地区的底图:另一类就是业务图,对于用于遥感数据发布的WebGIS应用就是遥感影像的边框图层,对于电力作业的就是杆塔.线路图层,对于水利作业的就是河流.居民地图层.