replaceLayer
Searches for a layer with the given name, and replaces it with new data. Is agnostic to the layer type(Polygon, marker, polyline). Cannot replace a layer with a different layer type. (EG: polygon → markers will not work)
Parameters:
layerName(string): The name of the layer to updatelayer(object): This can be any type of layer and will replace the layer of the same name
Returns: Nothing
Throws: Error in the console if a layer is not found with a name that matches layerName.
Code Sample