为什么此ngx-leaflet参数无法正常工作?

问题描述

我正在尝试通过leafletAngular的{​​{1}}项目中进行一切工作,但是找不到使它们正常工作的方法

这是我的params代码

ngx-angular

正如您在此快照上看到的那样,这行不通,zoomControl = {position: 'bottomright'}; readonly drawOptions = { position: 'topright',draw: { circle: false,circlemarker: false },edit: { featureGroup: this.drawItems,remove: false } }; 参数被忽略,position属性也被忽略。

enter image description here

当然,它们包含在具有circle and circlemarker属性调用div地图标记中,我想知道是否有可能在不使用纯JS的情况下使它们工作。

解决方法

使用ngx-leaflet-draw库可以实现您想要的目标。

在其中包含leafletDrawOptions等于在组件上定义的变量drawOptions

<div
  leaflet
  style="height: 400px;"
  leafletDraw
  [leafletOptions]="options"
  [leafletDrawOptions]="drawOptions"
  (leafletDrawCreated)="onDrawCreated($event)"
>
  <div [leafletLayer]="drawnItems"></div>
</div>

在您的组件中,您可以定义将显示哪些选项,就像您在上面的示例中尝试的那样:

{
    position: "topleft",draw: {
      ...,polyline: false,circle: false,circlemarker: false,rectangle: {
        shapeOptions: {
          color: "#85bb65"
        }
      }
    },edit: {
      featureGroup: this.drawnItems,remove: false
    }
  };

这里是guide,说明如何安装ngx-leaflet-draw,下面是demo,以了解其实时运行。不必担心图形图标不可见。在您的应用中应该没问题。它与codeandbox有关。