热门标签 | 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.


推荐阅读
  • 本文详细介绍了一种通过MySQL弱口令漏洞在Windows操作系统上获取SYSTEM权限的方法。该方法涉及使用自定义UDF DLL文件来执行任意命令,从而实现对远程服务器的完全控制。 ... [详细]
  • ElasticSearch 集群监控与优化
    本文详细介绍了如何有效地监控 ElasticSearch 集群,涵盖了关键性能指标、集群健康状况、统计信息以及内存和垃圾回收的监控方法。 ... [详细]
  • 本文介绍 SQL Server 的基本概念和操作,涵盖系统数据库、常用数据类型、表的创建及增删改查等基础操作。通过实例帮助读者快速上手 SQL Server 数据库管理。 ... [详细]
  • 主板IO用W83627THG,用VC如何取得CPU温度,系统温度,CPU风扇转速,VBat的电压. ... [详细]
  • 深入理解Vue.js:从入门到精通
    本文详细介绍了Vue.js的基础知识、安装方法、核心概念及实战案例,帮助开发者全面掌握这一流行的前端框架。 ... [详细]
  • 云函数与数据库API实现增删查改的对比
    本文将深入探讨使用云函数和数据库API实现数据操作(增删查改)的不同方法,通过详细的代码示例帮助读者更好地理解和掌握这些技术。文章不仅提供代码实现,还解释了每种方法的特点和适用场景。 ... [详细]
  • 1.执行sqlsever存储过程,消息:SQLServer阻止了对组件“AdHocDistributedQueries”的STATEMENT“OpenRowsetOpenDatas ... [详细]
  • 本文详细介绍了在 Windows 7 系统中配置 Nginx 1.10.3 和 PHP 7.1.1 NTS 的步骤,包括修改 PHP 配置文件、处理依赖项以及创建批处理脚本启动和停止服务。重点解释了如何解决常见的运行时错误。 ... [详细]
  • 深入解析RDMA中的队列对(Queue Pair)
    本文将详细探讨RDMA架构中的关键组件——队列对(Queue Pair,简称QP),包括其基本概念、硬件与软件实现、QPC的作用、QPN的分配机制以及用户接口和状态机。通过这些内容,读者可以更全面地理解QP在RDMA通信中的重要性和工作原理。 ... [详细]
  • python时间序列之ADF检验(1)
    读取数据,pd.read_csv默认生成DataFrame对象,需将其转换成Series对象DataFrame和Series是pandas中最常见的2 ... [详细]
  • OBS (Open Broadcaster Software) 架构解析
    本文介绍 OBS(Open Broadcaster Software),一款专为直播设计的开源软件。文章将详细探讨其技术架构、核心组件及其开发环境要求。 ... [详细]
  • Microsoft即将发布WPF/E的CTP(Community Technology Preview)和SDK,标志着RIA(Rich Internet Application)技术的新里程碑。更多详情及下载链接请参见MSDN官方页面。 ... [详细]
  • 本文介绍了如何在MATLAB中实现单变量线性回归,这是基于Coursera上Andrew Ng教授的机器学习课程中的一个实践项目。文章详细讲解了从数据可视化到模型训练的每一个步骤。 ... [详细]
  • 利用R语言进行股票价格数据的线性回归分析
    本文介绍了如何使用R语言对Excel中的股票价格数据集执行线性回归分析。通过具体的代码示例,展示了数据的导入、处理及模型构建的过程。 ... [详细]
  • 本文将探讨从ASP.NET 1.1到2.0期间编译系统的重要变革。通过对比两个版本的即时编译模型,我们将揭示2.0版本中引入的新特性和改进之处。 ... [详细]
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社区 版权所有