accept tiled, dynamic or feature layers for SQL query

logic added to handle differences
added option of layerId to the SQL Query parameter