use $closestMarkerIndex

without this fix `$markers[] = $closestMarker;` is about 5~10 times slower with simple test.