- } else { // OSM
- if (options.layers[layer] != 1) {
- l = options.layers[layer];
- fqdn = l.split("/")[2].split(".")
- text = fqdn[fqdn.length-2]
- map.addLayer(new OpenLayers.Layer.OSM("OpenStreetMap (" + text + ")", l));
- } else {
- map.addLayer(new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)"));
- }
+ } else if (layer == 'OSM') { // OSM default layer
+ map.addLayer(new OpenLayers.Layer.OSM("OSM (Mapnik)"));
+ } else { // assumed to be a URL
+ text = layer.match(/([^.\/]*\.[^.\/]*(\/[^\$]*)?)\/.*$/i) // take the first two parts of the FQDN and everything before the first $
+ map.addLayer(new OpenLayers.Layer.OSM("OSM (" + text[1] + ")", layer));