I want to write a JavaScript function that removes multiple map layers that have been added to a Leaflet map. I get an error Uncaught TypeError: Cannot use 'in' operator to search for '_leaflet_id'
Below is the function. With the first line I can print the name of each layer. But the second line in the function does not remove the layers, seems I can not pass the layer name so. I have tried to compare similar questions and go through the Leaflet documentation, but can not find the right solution.
function remover(element){
document.querySelectorAll('input[type="checkbox"]').forEach(e => console.log(e.id));
document.querySelectorAll('input[type="checkbox"]').forEach(e => map.removeLayer(e.id));
}
I get an error with Uncaught TypeError: Cannot use 'in' operator to search for '_leaflet_id'
Related
I currently do not have a reproducible example but will provide one asap.
I have a bokeh dashboard that updates with new data once a day and until this morning everything worked, so I can't explain right now why I am getting this error.
I have a JS callback that filters the data and the code runs fine up until updating the data source with source.change.emit();. This throws the error "Uncaught TypeError: value.toFixed is not a function".
Interestingly, the error only occurs when filtering for categories in a specific column, the same callback for categories in another column works perfectly fine. As said, until recently it worked for both columns.
Any idea if something on the bokeh side changed / what could cause the error?
Best,
Oliver
Sounds like a data issue
If value is not a number then it does not have a toFixed method to call.
If it is a string, cast it to number first, if null or undefined, cast it to 0 if needed
let a = 0
console.log(a.toFixed(2))
let b = ""
console.log(b.toFixed(2))
(I realize that iterating through an array with numeric indexes with for...in is bad practice (explained here) but I do not see how this is relevant here. I would like to understand why the problem described below happens. I lack the experience and skill to read through the CodeMirror source code to find out what went wrong unfortunately.)
Example app JSFiddle
There is a "2D array" generated here (array[]), 3 rows, each row consist of 4 elements (3 numbers and one \n character). My goal was to iterate through the whole "2D array" and put each character in the CodeMirror editor.
If you click on the "for...in" button, the code will do the first two rows of the array, then drops the following error:
Uncaught TypeError: Cannot read property 'chunkSize' of undefined
If you click on the "for...in that works" button, you will get the right result with no errors. The only difference between this and the previous function is that the "line" argument of the replaceRange method has a +1. This way it works perfectly for some reason
if you click on the "forEach" button, everything will work fine
I found about the fact that the "row" variable is the problem by trial and error.
So my questions are:
Why do I get the error above with the "for...in" button?
Why don't I get the error with the "for...in that works" button?
I am working with React Table. This is my Demo - https://codesandbox.io/s/m5nn9ko90p
I am trying to get the rowindex of some specific columns in my Table.
I am getting the index properly but I am getting this errors when I click on columns 11a and 11b:
Cannot read property 'col11aDataExpanded' of undefined
Cannot read property 'col11bDataExpanded' of undefined
Can you kindly look into this problem and update my CodeSandbox by getting rid of this issue.
Your const columns = [... array is defined outside your class, but you have callbacks, specifically your col11aDataExpanded and col11bDataExpanded callbacks that reference this, which is OFC undefined outside the class. Move your columns definition into your class and it'll work now.
https://codesandbox.io/s/x9r93koxn4
I get this error once I added the Where method, but it works without the Where clause. In collection every document has Boolean called "status".
db.firestore().collection('jobs').where("status","==",true).orderBy("createDate").limit(10).get().then(querySnapshot =>{
})
})
All Help is Appreciated. Thanks!
Since you're querying on two fields (status and createDate), there needs to be a composite index on those two fields. Indices on individual fields are automatically created, but composite indexes are only created when you ask for them.
The error message should contain a link directly to the console to complete that task. If that's not the case, you can create it here.
Firestore query on more than two fields requires a composite index on that two filed.
So you have to create composite index status and createDate.You will get the error like following when you don't have an index.
ERROR Error: The query requires an index. You can create it here: https://console.firebase.google.com/project/admin-e8a7b/database/firestore/indexes?create_index=EgR0ZW1wGgcKA3VpZBACGg0KCXN0YXJ0ZWRBdBADGgwKCF9fbmFtZV9fEAM
at new FirestoreError (vendor.bundle.js:19925)
So when you click this link in error index will be created automatically.
You can also manually create index from firebase console
To combine the equality operator (==) with a range comparison (<, <=, >, or >=), make sure to create a custom index.
I am looking to suppress missing values in a line graph using dimple.js, and I would like functionality equivalent to the svg.line().defined() method in d3.js: http://bl.ocks.org/mbostock/3035090
I attempted to modify the dimple.plot.line object to add in the .defined portion, but this did not seem to work. Is there any other way to do this?