Ionic ARCGIS功能群集无法处理点图形

gdx19jrr  于 2023-04-18  发布在  Ionic
关注(0)|答案(1)|浏览(139)

(this是一个来自Ionic/Angular项目的代码片段)我有一个数据库,在那里我存储了大约60 k个小行星的一些属性(如名称,纬度,经度)。我开始制作一个3D地球仪,并根据经纬度为每个小行星显示一个点,这很好。我现在想集群这些点以提高性能,并添加了featueReduction属性,正如你在我的代码中看到的:

ngAfterViewInit() {
    this.initGlobe()
  }

  async initGlobe() {
    esriConfig.apiKey = "SomeAPIKey";
    const loading = await this.loadingcontroller.create();
    await loading.present();
    this.map = new Map({
      basemap: "arcgis-imagery"
    });

    this.view = new SceneView({
      container: "viewDiv",
      map: this.map
    });

    await this.view.when(() => {
      console.log("map loaded")
      loading.dismiss();
      StatusBar.setStyle({style: Style.Dark});
      SplashScreen.hide();
    })
  }

  async loadPoints() {

    const simpleMarkerSymbol = {
      type: "simple-marker",
      color: [226, 119, 40],  // Orange
      outline: {
        color: [255, 255, 255], // White
        width: 1
      }
    };

    const loading = await this.loadingcontroller.create();
    await loading.present();
    this.databaseService.getAllAsteroids().subscribe(res => {
      this.allAsteroids = this.databaseService.mapToAsteroids(res.values);

      let graphics = this.allAsteroids.map(function (asteroid) {
        return new Graphic({
          geometry: new Point({
            latitude: asteroid.reclat,
            longitude: asteroid.reclong
          }),
          symbol: simpleMarkerSymbol
        });
      });


      let featureLayer = new FeatureLayer({
        source: graphics,
        renderer: new SimpleRenderer({
          symbol: new SimpleMarkerSymbol({
            color: "#102A44",
            outline: {
              color: "#598DD8",
              width: 2
            }
          })
        }),
        objectIdField: "ObjectID",
        fields: [
          {
            name: "ObjectID",
            alias: "ObjectID",
            type: "oid"
          },
          {
            name: "address",
            alias: "address",
            type: "string"
          }
        ],

//I ADDED THIS TO CLUSTER THE POINTS
        featureReduction: {
          type: "cluster",
          clusterMinSize: 16.5,
          // defines the label within each cluster
          labelingInfo: [
            {
              deconflictionStrategy: "none",
              labelExpressionInfo: {
                expression: "Text($feature.cluster_count, '#,###')"
              },
              symbol: {
                type: "text",
                color: "white",
                font: {
                  family: "Noto Sans",
                  size: "12px"
                }
              },
              labelPlacement: "center-center"
            }
          ],
        }
      });


      this.map.layers.add(featureLayer);

      loading.dismiss();
      StatusBar.setStyle({style: Style.Dark});
      SplashScreen.hide();

    })
  }

然而,它并没有改变任何东西。无论哪种方式,我的地球仪看起来像这样:
[](https://i.stack.imgur.com/9aPhN.png)
package.json:

"@ionic/angular": "^6.1.9",
"@angular/core": "^15.0.0",
"@types/arcgis-js-api": "^4.26.0"
"@arcgis/core": "^4.26.5",

谢谢你的帮助:)
我尝试添加featureReduction并期望基本集群

fae0ux8s

fae0ux8s1#

对于有同样问题的人:featureReduction不适用于sceneView(他们计划添加它,但尚未添加)。我只是在文档中监督它。因此,要么将sceneView转换为mapView,要么编写自己的聚类函数。

相关问题