Can’t use get_results() in ajax query

This will not work because you call example.com/markers.php directly, and that file does not load anything from WordPress, like the $wpdb object.

You can include wp-load.php, but this might break if you move the WordPress installation to somewhere else. To be more in line with how Ajax calls in WordPress should be made, you should write it as a hook for wp_ajax_[action]. See my introduction to Ajax in WordPress for more details.