热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ClusteringwiththeArcGISServerJavaScriptAPI(翻译)

About GeochalkboardAGISJavaScriptAPI PostsArcGISServerMastery ClubE-Learning CoursesInstructorLed CoursesPostedonSeptember9,2010.Filedunder:ArcGISServer,JavaScrip
  • About Geochalkboard
  • AGIS Javascript API Posts
  • ArcGIS Server Mastery Club
  • E-Learning Courses
  • Instructor Led Courses

Posted on September 9, 2010. Filed under: ArcGIS Server, Javascript |

In this post I will describe how you can use a third party clustering tool in your AGIS Javascript API applications.  Clustering is an excellent technique for visualizing lots of point data.  We’ve all seen applications where there were so many points that they simply appear as one big blob.  Clustering takes the individual points and groups them into clusters and then renders the cluster as one graphic.(在这个报告中,我将向你描述怎样使用一个第三方的cluster工具在你的Javascript api的应用中)

Those of you using either the AGIS API for Flex or Silverlight have easy access to clustering functionality built into the APIs.  However, this hasn’t yet been done for the Javascript API.  Fortunately, globoserve was provided with the clustering algorithm from ESRI and created a sub-classed GraphicsLayer to provide a third party adding clustering to your applications.  You can get additional information, see a demonstration, and download the Javascript files here.(使用Flex和Silverlight内置的API可以方便的访问cluster功能。然而,这并没有在Javascript API中实现)

I downloaded the Javascript files and incorporated them into a simple application that displays retail customer data as points on the map.  In the first figure I have displayed all the customer locations as points on a map.  This results in a somewhat cluttered display of markers.

Clustering with the ArcGIS Server Javascript API(翻译)

Next I applied clustering to the customer points which resulted in a much more appealing display.

Clustering with the ArcGIS Server Javascript API(翻译)

The clustering algorithm automatically creates the clusters and then re-creates the clusters as you zoom in.

Clustering with the ArcGIS Server Javascript API(翻译)

Let’s spend a little time discussing how you can easily integrate clustering in your application.  Here are the basic steps.

The first thing you’ll want to do is download the Javascript files that you’ll need.  You can get them here.  There are three files in the download.  The first, Ext.util.DelayedTask-nsRemoved.js is a copy of ExtJsDelayedTask class with its namespace removed.  There is not a whole lot to say about this file so I won’t.  Globoserve discusses this file in a bit more detail.  The second file, esri.ux.layers.ClusterLayer-debug.js does the work of creating the clusters.  In this file, the esri.layers.GraphicsLayer class is extended to create a new class called esri.ux.layers.ClusterLayer.  In your code you basically just create a new instance of ClusterLayer, pass in some parameters, and it does work of creating the clusters.  There is also a “-min” version of this file which cuts down the size of the file for performance reasons.

Now that you’ve downloaded the files you can code your application to take advantage of the clustering.  There are a couple requirements.  First, the clustering algorithm uses the basemap’s tiling scheme for  its “grid” which means you will need a tiled basemap.  The WKID of the features being clustered should also be one of the following:

  • Projected: 102100, 102113
  • Geographic: 4326, 4269, 4267
  • Or matching the WKID of the basemap

On to the code.  I’ve created a displayCustomers() function which executes when the user clicks the Display button.  Inside this function I first create a QueryTask object that points to my customer layer.  This is a tiled map service.  I also create a Query object and set several parameters.  This Query object acts as input to the QueryTask object.  Here we have defined parameters to return the geometry of the features, return all records (1=1) and specified that we’d like to return the Address and LastName fields.  This is highlighted in green in the figure below.

Clustering with the ArcGIS Server Javascript API(翻译)

Once the QueryTask has finished executing a featureSet is returned to the callback function which creates a new ClusterLayer object.  Several parameters are supplied for the creation of this object.

  • map – refers to an esri.Map objects from the AGIS API
  • features – this is just a reference to the featureSet that was returned from the QueryTask execution
  • infoWindow – configuration options for the infoWindow that will appear when you hover over each individual graphic point.  You can see an example of this below.
  • flareLimit – the number of “flare graphics” that can appear around a cluster (default is 20)
  • flareDistanceFromCenter – the distance in pixels that the flare graphics appear from the center of their cluster.

From there we simply call Map.addLayer passing in our new instance of the ClusterLayer object.  That’s pretty much all there is to it.  I’ve included some screenshots below to show the flaring and infoWindows.  Once again, thanks to Adam at globoserve for creating this really useful functionality that many of you will no doubt use in your applications.

Clustering with the ArcGIS Server Javascript API(翻译)

Clustering with the ArcGIS Server Javascript API(翻译)

The next session of our Mastering the ArcGIS Server Javascript API begins October 4th, 2010.  We still have seats available.


推荐阅读
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • 本文介绍了使用哈夫曼树实现文件压缩和解压的方法。首先对数据结构课程设计中的代码进行了分析,包括使用时间调用、常量定义和统计文件中各个字符时相关的结构体。然后讨论了哈夫曼树的实现原理和算法。最后介绍了文件压缩和解压的具体步骤,包括字符统计、构建哈夫曼树、生成编码表、编码和解码过程。通过实例演示了文件压缩和解压的效果。本文的内容对于理解哈夫曼树的实现原理和应用具有一定的参考价值。 ... [详细]
  • 本文讨论了在VMWARE5.1的虚拟服务器Windows Server 2008R2上安装oracle 10g客户端时出现的问题,并提供了解决方法。错误日志显示了异常访问违例,通过分析日志中的问题帧,找到了解决问题的线索。文章详细介绍了解决方法,帮助读者顺利安装oracle 10g客户端。 ... [详细]
  • eclipse学习(第三章:ssh中的Hibernate)——11.Hibernate的缓存(2级缓存,get和load)
    本文介绍了eclipse学习中的第三章内容,主要讲解了ssh中的Hibernate的缓存,包括2级缓存和get方法、load方法的区别。文章还涉及了项目实践和相关知识点的讲解。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • 本文介绍了使用Python解析C语言结构体的方法,包括定义基本类型和结构体类型的字典,并提供了一个示例代码,展示了如何解析C语言结构体。 ... [详细]
  • 本文介绍了一个免费的asp.net控件,该控件具备数据显示、录入、更新、删除等功能。它比datagrid更易用、更实用,同时具备多种功能,例如属性设置、数据排序、字段类型格式化显示、密码字段支持、图像字段上传和生成缩略图等。此外,它还提供了数据验证、日期选择器、数字选择器等功能,以及防止注入攻击、非本页提交和自动分页技术等安全性和性能优化功能。最后,该控件还支持字段值合计和数据导出功能。总之,该控件功能强大且免费,适用于asp.net开发。 ... [详细]
  • 实现一个通讯录系统,可添加、删除、修改、查找、显示、清空、排序通讯录信息
    本文介绍了如何实现一个通讯录系统,该系统可以实现添加、删除、修改、查找、显示、清空、排序通讯录信息的功能。通过定义结构体LINK和PEOPLE来存储通讯录信息,使用相关函数来实现各项功能。详细介绍了每个功能的实现方法。 ... [详细]
  • EPPlus绘制刻度线的方法及示例代码
    本文介绍了使用EPPlus绘制刻度线的方法,并提供了示例代码。通过ExcelPackage类和List对象,可以实现在Excel中绘制刻度线的功能。具体的方法和示例代码在文章中进行了详细的介绍和演示。 ... [详细]
  • java drools5_Java Drools5.1 规则流基础【示例】(中)
    五、规则文件及规则流EduInfoRule.drl:packagemyrules;importsample.Employ;ruleBachelorruleflow-group ... [详细]
  • 本文介绍了一种图的存储和遍历方法——链式前向星法,该方法在存储带边权的图时时间效率比vector略高且节省空间。然而,链式前向星法存图的最大问题是对一个点的出边进行排序去重不容易,但在平行边无所谓的情况下选择这个方法是非常明智的。文章还提及了图中搜索树的父子关系一般不是很重要,同时给出了相应的代码示例。 ... [详细]
author-avatar
翡翠雕刻师李贵
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有