Skip to content

Instantly share code, notes, and snippets.

@mikeyk
Created October 20, 2009 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyk/214070 to your computer and use it in GitHub Desktop.
Save mikeyk/214070 to your computer and use it in GitHub Desktop.
NSMutableDictionary * hashedLocations = [NSMutableDictionary dictionaryWithCapacity:100];
NSArray * lastResultList = [dataSource locations];
for (InfoLocation * infoloc in lastResultList) {
InfoLocation * infoLocCopy = [[InfoLocation alloc] initWithInfoLocation:infoloc];
CLLocationCoordinate2D coord = [infoloc coordinate];
NSString * hash = [NSString stringWithFormat:@"%.5f-%.5f", coord.latitude, coord.longitude];
if (![hashedLocations objectForKey:hash]) {
[hashedLocations setValue:[[NSNumber alloc] initWithInt:1] forKey:hash];
} else {
// offset a bit so we don't have a bunch of clustered ones
int interval = [[infoLocCopy timestamp] timeIntervalSince1970];
float latoffset = ((interval % 128) / 64.0) - 1;
float lonoffset = ((interval % 142) / 71.0) - 1;
coord.latitude += latoffset / 1300.0;
coord.longitude += lonoffset / 1300.0;
[infoLocCopy setCoordinate:coord];
}
[mainMapView addAnnotation:infoLocCopy];
[infoLocCopy release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment