Hi Mykola,
Please follow the instructions that Magda gave you regarding attaching events to markers as a first step. I would also recommend that you try to use the map inputs, instead of adding the markers yourself through javascript.
If you need to use javascript, try to create a bound and then add the markers to the map and to the bound, after adding the markers do a map fit to bounds for the bound you created.
Let me know if this helps,
Thanks,
Hugo