An on-duty New York City police officer was killed on Wednesday after a man walked up to her police vehicle and began to fire shots through the window, authorities said.