Code Monkey home page Code Monkey logo

Comments (9)

jteppinette avatar jteppinette commented on August 26, 2024

@fergardi I received this same error. I resolved it by placing a v-if="map.vectors && map.vectors.length" (adjusted for variable names) on the map's parent element.

I believe the issue is from the map attempt attempting to instantiate layers before the GeoJSON is ready.

from vue2leaflet.

fergardi avatar fergardi commented on August 26, 2024

In order to check this behaviour, I added directly the geojson in the created hook, so its ready when it tries to render the layer. Not working, but thanks for the response.

from vue2leaflet.

KoRiGaN avatar KoRiGaN commented on August 26, 2024

Hi @fergardi,

Could you please provide a link to a jsfiddle for example that reproduce this issue.

I'm not sure how to reproduce this.
Thanks

from vue2leaflet.

AchilleAsh avatar AchilleAsh commented on August 26, 2024

Hi @fergardi,

Just had the same issue while trying to load GeoJSON from a REST API (loading from hardcoded values works fine), and I’ve found a fix after reading the code.

The error is in GeoJSON.vue component, line 11 :

    if (this.$parent._isMounted) {
>>   this.deferredMountedTo(this.$parent.$geoJSON);
    }

The parent of the GeoJSON layer is undefined, as we try to access $geoJSON attribute of this.$parent, which is the Vue Component of the map. So later in deferredMountedTo, we call this.$geoJSON.addTo(parent) and that’s causing the error : $geojson is undefined in this.$parent.

So replace this.$parent.$geoJSON with this.$parent.mapObject and now it’s working properly (at least in my app, let me know if it fixes your too)

@KoRiGaN I think you can reproduce this bug by using a delayed load of hardcoded values (ie. simulating an async call to an API)

Cheers

from vue2leaflet.

KoRiGaN avatar KoRiGaN commented on August 26, 2024

Hi @fergardi,

I had a look and your right about the issue and was able to reproduce it by loading geojson asynchronously.
The fix you suggested also work so I push it on a new version 0.0.51.
Thanks for the great help !

@fergardi and @jteppinette, can you confirm it also fix your issues with the GeoJSON component ?

Micka

from vue2leaflet.

KoRiGaN avatar KoRiGaN commented on August 26, 2024

@fergardi @jteppinette any update ?

from vue2leaflet.

KoRiGaN avatar KoRiGaN commented on August 26, 2024

Closed as no answer for 2 weeks

from vue2leaflet.

bidhan-a avatar bidhan-a commented on August 26, 2024

Hi, I'm still facing this issue on version 0.0.51.

from vue2leaflet.

AchilleAsh avatar AchilleAsh commented on August 26, 2024

@KoRiGaN (cc @bidhan-a ),

I've checked your fix, there is a typo (on line 11)
this.$parent.$mapObject should be this.$parent.mapObject

There is a $ right before mapObject, that's why it's not working.

Timothé

from vue2leaflet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.