The for loop should check for the searchbox and return nothing if empty or add a null object to an array marker which should hold as a placeholder for markers (in code markers is mainMarkers to prevent confusion).
The for loop returns an Type Error because the array Cannot read property '0' of undefined.
According to MDN documentation, you can use javascript return as a way of stopping a function, which makes sense for a searchbox with no elements. However, in practice an error occurs.
The same error occurs later in the for loop with the marker null object.
The code seems to run fine without this since it's just supposed to be a check, but it's weird that this happened. Any thoughts?
Line 28 of the JS file contains a for loop that was pasted from the Google SearchBox example.
The for loop should check for the searchbox and return nothing if empty or add a null object to an array marker which should hold as a placeholder for markers (in code markers is mainMarkers to prevent confusion).
The for loop returns an Type Error because the array Cannot read property '0' of undefined.
According to MDN documentation, you can use javascript return as a way of stopping a function, which makes sense for a searchbox with no elements. However, in practice an error occurs.
The same error occurs later in the for loop with the marker null object.
The code seems to run fine without this since it's just supposed to be a check, but it's weird that this happened. Any thoughts?