'Get a JSON representation of this map suitable for sending to geoserver
for creating a download of all layers'

def json(self, layer_filter):

    map_layers = MapLayer.objects.filter(map=self.id)
    layers = []
    for map_layer in map_layers:
        if map_layer.local:
            layer = Layer.objects.get(alternate=map_layer.name)
            layers.append(layer)
        else:
            pass
    if layer_filter:
        layers = [l for l in layers if layer_filter(l)]
    readme = ((('Title:    %s\n' + 'Author:    %s\n') + 'Abstract:    %s\n') % (self.title, self.poc, self.abstract))
    if self.license:
        readme += ('License:    %s' % self.license)
        if self.license.url:
            readme += ('    (%s)' % self.license.url)
        readme += '\n'
    if self.constraints_other:
        readme += ('Additional    constraints:    %s\n' % self.constraints_other)
    def layer_json(lyr):
        return {'name': lyr.alternate, 'service': lyr.service_type, 'serviceURL': '', 'metadataURL': ''}
    map_config = {'map': {'readme': readme, 'title': self.title}, 'layers': [layer_json(lyr) for lyr in layers]}
    return json.dumps(map_config)
