Skip to content

Commit da8c361

Browse files
author
Andrew Chae
committed
Use short name for thoroughfare if it's used in the formatted address
1 parent 85ef3da commit da8c361

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

SVGeocoder/SVPlacemark.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ - (id)initWithDictionary:(NSDictionary *)result {
4848
if([types containsObject:@"street_number"])
4949
self.subThoroughfare = [component objectForKey:@"long_name"];
5050

51-
if([types containsObject:@"route"])
52-
self.thoroughfare = [component objectForKey:@"long_name"];
51+
if([types containsObject:@"route"]) {
52+
NSString *shortName = [component objectForKey:@"short_name"];
53+
if ([self.formattedAddress rangeOfString:shortName].location != NSNotFound) {
54+
self.thoroughfare = shortName;
55+
} else {
56+
self.thoroughfare = [component objectForKey:@"long_name"];
57+
}
58+
}
5359

5460
if([types containsObject:@"administrative_area_level_3"] || [types containsObject:@"sublocality"] || [types containsObject:@"neighborhood"])
5561
self.subLocality = [component objectForKey:@"long_name"];

0 commit comments

Comments
 (0)