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.

    官方实例在这。点击下载

    纸上得来终觉浅,绝知此事要躬行
  • 相关阅读:
    痞子衡嵌入式:在i.MXRT启动头FDCB里调整Flash工作频率也需同步设Dummy Cycle (以IS25WP128为例)
    《痞子衡嵌入式半月刊》 第 29 期
    痞子衡嵌入式:从头开始认识i.MXRT启动头FDCB里的lookupTable
    痞子衡嵌入式:MCUXpresso IDE下在线调试时使用不同复位策略的现象总结
    痞子衡嵌入式:关于恩智浦入驻B站的一些思考
    《痞子衡嵌入式半月刊》 第 28 期
    痞子衡嵌入式:分享一个i.MXRT系列配套DRAM压力测试上位机工具(i.MXRT DRAM Tester)
    痞子衡嵌入式:在i.MXRT1060-EVK上利用memtester程序给SDRAM做压力测试
    痞子衡嵌入式:内存读写正确性压力测试程序(memtester)
    痞子衡嵌入式:盘点国内MCU级RISC-V内核IP厂商
  • 原文地址:https://www.cnblogs.com/d2ee/p/3623687.html
Copyright © 2011-2022 走看看