geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

TypeError: Cannot read property 'optIn' of undefined #1220

Closed alphaev9 closed 2 years ago

alphaev9 commented 2 years ago

i use leaflet-geoman with vue3,when i run the project,sometimes ok,sometimes an error reported like this:

22:22:53.144 TypeError: Cannot read property 'optIn' of undefined
22:22:53.185 at NewClass.proto.callInitHooks (file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/app-renderjs.js:8177:36)
22:22:53.206 at NewClass.initialize (file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/app-renderjs.js:9593:18)
22:22:53.227 at new NewClass (file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/app-renderjs.js:8140:31)
22:22:53.247 at Object.createMap (file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/app-renderjs.js:10498:18)
<script module="locatemap" lang="renderjs">
    import * as L from 'leaflet'
    import '../util/flat.js'
    import '@geoman-io/leaflet-geoman-free'
    export default {
        data() {
            return {
                map: null,
            }
        },
        created() {
            this.map = L.map('leaflet-container', {
                pmIgnore: true,
                attributionControl: false,
                touchZoom: 'center',
                minZoom: 1,
                maxZoom: 4,
                worldCopyJump: true
            }).fitWorld()
        }
    }
</script>
Falke-Design commented 2 years ago

Looks like L.PM is not global accessible.

Try to import geoman and then check console.log(L.PM).

I can't help much without a demo.

alphaev9 commented 2 years ago

已收到