Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error ReferenceError: len3 is not defined when adding layer to map #10

Open
MicahDavid opened this issue Jan 17, 2023 · 1 comment
Open

Comments

@MicahDavid
Copy link

I am trying to create an interpolated leaflet layer in my Vue JS application.

I am receiving the following error when adding the idw layer to my map:

error ReferenceError: len3 is not defined

Here is my code:

        let dataArray = []
        filteredListData.value.forEach((data) => {
            dataArray.push([data.lat, data.lng, data.val])
        })
        const idw = L.idwLayer(dataArray, {opacity: 0.3, cellSize: 10, exp: 2, max: 50}).addTo(map.value)

If I don't addTo(), then the idw layer is created successfully.
console.log(idw) looks like this:

NewClass {options: {…}, _latlngs: Array(55), _initHooksCalled: true}
options
: 
{opacity: 0.3, cellSize: 10, exp: 2, max: 50}
_initHooksCalled
: 
true
_latlngs
: 
(55) [Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3), Array(3)]
[[Prototype]]
: 
NewClass

The latlngs array looks like this:

0
: 
(3) [39.390906, -75.62808, 39.6]
1
: 
(3) [39.088212, -75.437285, 40.7]
2
: 
(3) [38.536626, -75.054492, 41.8]
3
: 
(3) [39.864455, -75.842194, 36.5]

Any suggestions are greatly appreciated!

@MicahDavid
Copy link
Author

For anyone else encountering this error, it was just some js syntax that needed to be updated. I suppose this is with the ES6 javascript variable requirements. There were 2 js errors I needed to get around:

error ReferenceError: len3 is not defined

I just defined len3 like so:
let len3

Also, I needed to change this line:

interpolVal = numerator/denominator;

to:

const interpolVal = numerator/denominator;

Hope that helps anyone else trying to use this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant