Skip to content

Error: Draw not defined #156

Open
Open
@qooco

Description

@qooco

Angular 18 esbuild:
Cannot read properties of undefined (reading 'Event')
Draw is not defined
map.on(Draw.Event.CREATED, (e: any) => LeafletUtil.handleEvent(this.zone, this.onDrawCreated, e));

Fix:
projects/ngx-leaflet-draw/src/lib/core/leaflet-draw.directive.ts

Change imports order:
import { Control, Draw, DrawEvents, drawLocal } from 'leaflet';
import 'leaflet-draw';

To:
import 'leaflet-draw';
import { Control, Draw, DrawEvents, drawLocal } from 'leaflet';

Then Draw will be defined, and it solves the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions