MapofLife/MOL — Issue #33: Multiple layer overlays
Author: eightysteele
Created: 2012-01-27 21:01:32+00:00
State: open
Labels: UI

We need a check in `mol.map.tiles.js` to ensure that we don't add the same layer multiple times to the map. Here's the entry point where layers are handled in the module:

https://github.com/MapofLife/MOL/blob/develop/app/js/mol.map.tiles.js#L47

The `layers` here are an array of layer objects. Each layer is identified by `layer-{name}-{types}`. For example:

```javascript
layer = {name: 'Puma concolor', type: 'polygon'};
id = layer-{0}-{1}'.format(layer.name, layer.type);
```

Since map layers in the map have the id, we just need to iterate over the map layers to see if there's a matching id:

```javascript
this.map.overlayMapTypes.forEach(...);
```

See this for details on the `forEach` function:

http://code.google.com/apis/maps/documentation/javascript/reference.html#MVCArray