Fix Bugs And Update Setmap Function to use AJAX