That means that no Software Serial is available on D2:
Is D2 connected to the TX pin of the Neo-6M module that would emit GPS data? From what you've shown, that might not be true.
Please post pictures and schematics as per:
Also, since loop() already loops, you could change the 'while' to an 'if'.