refactor js code for using several instances of GPXMap