往 can be used as a verb and a preposition.
These are several samples of 往 as a preposition:
(1) 往 used to indicate the direction of an action. It used with an adverb of place, and placed before the verb.
i.e.: - 往南边走 (to walk towards the south)
- 往西边飞 (to fly towards the west)
(2) 往 can be also placed after a few of verbs, such as 开，飞，送，寄，逃.
- 车开往城里去 (the bus goes to town)
- 他们飞往美国去了 (They flew to the US)
Hope they help. Please do not hesitate to ask me, if you require further question.