def encode_multiple_layers(out, features_by_layer, zoom):
    """
    features_by_layer should be a dict: layer_name -> feature tuples
    """
    precision = precision_for_zoom(zoom)
    geojson = {}
    for layer_name, features in features_by_layer.items():
        fs = create_layer_feature_collection(features, precision)
        geojson[layer_name] = fs
    json.dump(geojson, out)