Effect of ionic lattices on electronic structures of polyatomic ions