微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决为什么此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有关。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。