I have found similar questions about creating functions with optional parameters. But I continually run into errors is the parameter may not exist. I have an interactive map that is doing a bunch of things. However if outputlayer is null, the function will not execute. This layer may or may not exist. I just can’t seem to figure out how to pass this optional parameter in if it doesn’t exist. Thanks for any help!
function appdelete(selected,vectorlayer,drawFeature,outputlayer) {
$(selected).prev().children().children().eq(2).val('Latitude');
$(selected).prev().children().children().eq(4).val('Longitude');
vectorlayer.destroyFeatures();
drawFeature.activate();
try {
map.removeLayer(outputlayer);
} catch(err) { };
}
Check if it exists first and maybe the type.