Yes.
The iPhone (among many others) constantly receive discovery packets from other Wireless Access Points (WAP) while it's out and about. These packets contain unique IDs and whenever location services is activated, it'll send a recent bunch of these to Apple's version of Skyhook (a WAP location database) so it'll find your rough location real quick.
Simply put it's going: hey, I was near a place called this, tell me where this is.