zoukankan      html  css  js  c++  java
  • 【ArcGIS for JavaScript api】Clusterlayer聚簇类

    1.作用:

           聚簇类是用于前端显示优化,使POI点要素显示更为美观。大量的Marker距离太近会引起压盖而对浏览或者操作产生不便,因此,一般在超过1K点的时候,用此类。、

    2.使用方式:

       1:  // cluster layer that uses OpenLayers style clustering
       2:              clusterLayer = new ClusterLayer({
       3:                "data": photoInfo.data,
       4:                "distance": 100,
       5:                "id": "clusters",
       6:                "labelColor": "#fff",
       7:                "labelOffset": 10,
       8:                "resolution": map.extent.getWidth() / map.width,
       9:                "singleColor": "#888",
      10:                "maxSingles":1999,
      11:                "singleTemplate": popupTemplate
      12:              });
      13:              var defaultSym = new SimpleMarkerSymbol().setSize(4);
      14:              var renderer = new ClassBreaksRenderer(defaultSym, "clusterCount");
      15:   
      16:              var picBaseUrl = "http://static.arcgis.com/images/Symbols/Shapes/";
      17:              var blue = new PictureMarkerSymbol(picBaseUrl + "BluePin1LargeB.png", 32, 32).setOffset(0, 15);
      18:              var green = new PictureMarkerSymbol(picBaseUrl + "GreenPin1LargeB.png", 64, 64).setOffset(0, 15);
      19:              var red = new PictureMarkerSymbol(picBaseUrl + "RedPin1LargeB.png", 72, 72).setOffset(0, 15);
      20:              renderer.addBreak(0, 2, blue);
      21:              renderer.addBreak(2, 200, green);
      22:              renderer.addBreak(200, 1001, red);
      23:   
      24:              clusterLayer.setRenderer(renderer);

    25: map.addLayer(clusterLayer);

     

    构造函数源码重点:

    return declare([GraphicsLayer], {
        constructor: function(options) {
          // options:
          //   data:  Object[]
          //     Array of objects. Required. Object are required to have properties named x, y and attributes. The x and y coordinates have to be numbers that represent a points coordinates.要素对象集合是必要字段。而要素是Json格式,有三个key,x,y,attributes,坐标值之外的属性数据全部放在attributes字段里。
          //   distance:  Number?
          //     Optional. The max number of pixels between points to group points in the same cluster. Default value is 50.该字段是设定两点之间小于多少个像素值就被归类于同一个簇中

                  默认值是50.
          //   labelColor:  String?
          //     Optional. Hex string or array of rgba values used as the color for cluster labels. Default value is #fff (white).
          //   labelOffset:  String?
          //     Optional. Number of pixels to shift a cluster label vertically. Defaults to -5 to align labels with circle symbols. Does not work in IE.
          //   resolution:  Number
          //     Required. Width of a pixel in map coordinates. Example of how to calculate:
          //     map.extent.getWidth() / map.width
          //   showSingles:  Boolean?
          //     Optional. Whether or graphics should be displayed when a cluster graphic is clicked. Default is true.
          //   singleSymbol:  MarkerSymbol?
          //     Marker Symbol (picture or simple). Optional. Symbol to use for graphics that represent single points. Default is a small gray SimpleMarkerSymbol.
          //   singleTemplate:  PopupTemplate?
          //     PopupTemplate</a>. Optional. Popup template used to format attributes for graphics that represent single points. Default shows all attributes as "attribute = value" (not recommended).
          //   maxSingles:  Number?
          //     Optional. Threshold(阈值) for whether or not to show graphics for points in a cluster. Default is 1000.
          //   webmap:  Boolean?
          //     Optional. Whether or not the map is from an ArcGIS.com webmap. Default is false.
          //   spatialReference:  SpatialReference?
          //     Optional. Spatial reference for all graphics in the layer. This has to match the spatial reference of the map. Default is 102100. Omit this if the map uses basemaps in web mercator.

    官方实例在这。点击下载

    纸上得来终觉浅,绝知此事要躬行
  • 相关阅读:
    puppeteer,新款headless chrome!
    圣诞快乐,而且写博客有两年了~
    es2015及es2017对我们的编程方式造成了什么影响?
    Redis的安装和部署
    ActiveMQ5.0实战三:使用Spring发送,消费topic和queue消息
    hsweb 企业后台管理基础框架
    通过Spring Session实现新一代的Session管理
    mod_pagespeed
    unusedjs
    apache模块 合并多个js/css 提高网页加载速度
  • 原文地址:https://www.cnblogs.com/d2ee/p/3623687.html
Copyright © 2011-2022 走看看