'@param marker: Storage object with image/height/width (looked-up in bulk)
@param marker_id: id of record in gis_marker
@param layer_id: layer_id to lookup marker in gis_style (unused)
@param tablename: used to identify whether to provide a default marker as fallback'

def __init__(self, marker=None, marker_id=None, layer_id=None, tablename=None):

    no_default = False
    if (not marker):
        db = current.db
        s3db = current.s3db
        mtable = s3db.gis_marker
        config = None
        if marker_id:
            marker = db((mtable.id == marker_id)).select(mtable.image, mtable.height, mtable.width, limitby=(0, 1), cache=s3db.cache).first()
        elif layer_id:
            config = GIS.get_config()
            stable = s3db.gis_style
            query = ((((stable.layer_id == layer_id) & ((stable.config_id == config.id) | (stable.config_id == None))) & (stable.marker_id == mtable.id)) & (stable.record_id == None))
            marker = db(query).select(mtable.image, mtable.height, mtable.width, limitby=(0, 1)).first()
    if (not marker):
        if (tablename == 'gis_layer_shapefile'):
            table = db.gis_layer_shapefile
            query = (table.layer_id == layer_id)
            layer = db(query).select(table.gis_feature_type, limitby=(0, 1)).first()
            if (layer and (layer.gis_feature_type != 1)):
                no_default = True
    if marker:
        self.image = marker['image']
        self.height = marker['height']
        self.width = marker['width']
    elif no_default:
        self.image = None
    else:
        if (not config):
            config = GIS.get_config()
        self.image = config.marker_image
        self.height = config.marker_height
        self.width = config.marker_width
