标签: esri-javascript-api

angular 5应用程序中的@ types / arcgis-js-api

我在我的angular5应用程序中使用arcgis-js-api类型。当我尝试在多个组件中导入类型时,我遇到了未引用的错误:__esri未定义。我在tsconfig.app.json文件的类型数组中包含了arcgis-js-api。这是我的代码。

  import { Component, OnInit, Input, ViewChild, ElementRef } from 
'@angular/core';
  import * as esriLoader from 'esri-loader';
  import { environment } from '../../../environments/environment';
  import Esri = __esri;

  @Component({
    selector: 'app-custom-widget',
    templateUrl: './custom-widget.component.html',
    styleUrls: ['./custom-widget.component.css']
  })
  export class CustomWidgetComponent implements OnInit {
    private _mapView: Esri.MapView;
    private _scriptOptions: any;

    @ViewChild('customWidget') widgetElement: ElementRef;
    @Input()
    set mapView(mapView: Esri.MapView) {
      if (!mapView) {
        return;
      }
      this._mapView = mapView;
      this.renderWidget();
    }
    get mapView(): Esri.MapView {
      return this._mapView;
    }

    constructor() {
      this._scriptOptions = {
        url: environment.arcgisAPIVersion
      }; …
Run Code Online (Sandbox Code Playgroud)

typescript esri-javascript-api

6
推荐指数
1
解决办法
351
查看次数

Esri Maps PopupTemplate的内容方法每个功能仅调用一次

我正在Angular应用程序内使用Esri映射,并且将弹出式窗口渲染为Angular组件,并使用PopupTemplatecontent方法发布了数据:

layer.popupTemplate = new PopupTemplate({
  content: (feature: { graphic: __esri.Graphic }) => {
    this.publishPopupData(layer, feature.graphic.attributes);
    return popupComponent.viewContainerRef.element.nativeElement;
  },
  // other properties... 
});
Run Code Online (Sandbox Code Playgroud)

这很好用,除非在给定点有多个要素。当用户循环浏览功能时,如果他/她返回到已经显示的功能,则不会执行content方法,因此不会发布弹出数据。

我可以在MapView的弹出窗口中访问当前选择的功能,但是我需要知道该功能来自哪一层才能正确发布数据(每一层对将ArcGIS数据处理到弹出窗口所使用的模型中都有独特的要求) 。

mapView.popup.watch('selectedFeature', (graphic: __esri.Graphic) => {
  const layer = ???;
  this.publishPopupData(layer, graphic.attributes);
});
Run Code Online (Sandbox Code Playgroud)

名义上,graphic.layer应该包含图层参考,但就我而言,它始终是null

有没有一种方法可以强制弹出窗口始终调用content方法,即使该方法已经针对给定功能执行了呢?或者,是否有办法获取要素所属的图层MapView.popup(或我未考虑的其他内容)?

如果重要的话,弹出窗口用于MapImageLayer子层。

esri typescript arcgis-js-api esri-maps esri-javascript-api

5
推荐指数
1
解决办法
307
查看次数