Angular 角度项目中的OpenLayers自定义控件

Angular 角度项目中的OpenLayers自定义控件,angular,typescript,inheritance,openlayers,Angular,Typescript,Inheritance,Openlayers,我想在Angular项目中使用OpenLayers基类创建自己的自定义控件 我有一个组件如下所示: 控件.component.ts import { Component, OnInit, Host } from '@angular/core'; import { MapService } from '../map.service'; import { MapidService } from '../mapid.service'; import { Map } from 'ol'; import

我想在Angular项目中使用OpenLayers基类创建自己的自定义控件

我有一个组件如下所示:

控件.component.ts

import { Component, OnInit, Host } from '@angular/core';

import { MapService } from '../map.service';
import { MapidService } from '../mapid.service';
import { Map } from 'ol';
import MyCustomControl from '../somewhere/my-custom-control';

@Component({
  selector: 'app-control',
  templateUrl: './control.component.html',
  styleUrls: ['./control.component.css']
})
export class ControlComponent implements OnInit {

  constructor(
    private mapService: MapService,
    @Host()
    private mapidService: MapidService) { }

  ngOnInit(): void {
    // Get the current map
    const map: Map = this.mapService.getMap(this.mapidService.getId());
    const control = new MyCustomControl({});
    map.addControl(control);
  }

}
我想为我的自定义组件创建一个类,但是,由于这是我在Angular项目中第一次必须这样做(也就是说,创建一个不是带有
ng g class mycustomclass
的组件的类),我真的不知道哪种方法是最好的方法

我尤其怀疑:

  • 我应该将这个新类放在哪个文件夹中
  • 如果我用这样的东西声明我的新类可以吗

  • 在Angular中(我习惯于在“普通”类型脚本项目中这样做),或者有更好的方法(另一个组件)?

    我使用const el=document.createElement()为控件创建元素,const control=new control({element:el});map.addControl(control)@unbe1987您找到解决方案了吗?我正在使用const el=document.createElement()为控件创建元素,const control=new控件({element:el});map.addControl(control)@unbe1987您找到解决方案了吗??
    export class MyCustomControl extends Control {
       constructor() {
          super({});
          ...
       }
    }