diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-01-04 17:13:55 -0600 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-01-04 17:13:55 -0600 |
commit | 6fa57b7d48b6f0505166b8d3a940eaaf1ab5a18f (patch) | |
tree | 14e8ea93393095746e208b23c2358d13658ae17a /platform/darwin/src/MGLAttributionInfo.mm | |
parent | 5bfa20d71dc099416c5d715e7857ae836db160ed (diff) | |
parent | 187b6dc31cf281b5157de1acd92f3e8ef9d0acf9 (diff) | |
download | qtlocation-mapboxgl-6fa57b7d48b6f0505166b8d3a940eaaf1ab5a18f.tar.gz |
Merge branch 'release-agua' back to master.
Diffstat (limited to 'platform/darwin/src/MGLAttributionInfo.mm')
-rw-r--r-- | platform/darwin/src/MGLAttributionInfo.mm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index ce63a25422..73147270c1 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -127,6 +127,15 @@ return self; } +- (id)copyWithZone:(nullable NSZone *)zone +{ + MGLAttributionInfo *info = [[[self class] allocWithZone:zone] initWithTitle:_title + URL:_URL]; + info.feedbackLink = _feedbackLink; + + return info; +} + - (nullable NSURL *)feedbackURLAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel { return [self feedbackURLForStyleURL:nil atCenterCoordinate:centerCoordinate zoomLevel:zoomLevel direction:0 pitch:0]; } @@ -160,6 +169,25 @@ return components.URL; } +- (NSAttributedString *)titleWithStyle:(MGLAttributionInfoStyle)style +{ + NSString *openStreetMap = NSLocalizedStringWithDefaultValue(@"OSM_FULL_NAME", @"Foundation", nil, @"OpenStreetMap", @"OpenStreetMap full name attribution"); + NSString *OSM = NSLocalizedStringWithDefaultValue(@"OSM_SHORT_NAME", @"Foundation", nil, @"OSM", @"OpenStreetMap short name attribution"); + + NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithAttributedString:self.title]; + [title removeAttribute:NSUnderlineStyleAttributeName range:NSMakeRange(0, [title.string length])]; + + BOOL isAbbreviated = (style == MGLAttributionInfoStyleShort); + + if ([title.string rangeOfString:@"OpenStreetMap"].location != NSNotFound) { + [title.mutableString replaceOccurrencesOfString:@"OpenStreetMap" withString:isAbbreviated ? OSM : openStreetMap + options:NSCaseInsensitiveSearch + range:NSMakeRange(0, [title.mutableString length])]; + } + + return title; +} + - (BOOL)isEqual:(id)object { return [object isKindOfClass:[self class]] && [[object title] isEqual:self.title] && [[object URL] isEqual:self.URL]; } |