Authored by Justin R. Miller

added circle annotation

... ... @@ -31,6 +31,7 @@
#import "RMAnnotation.h"
#import "RMCacheObject.h"
#import "RMCircle.h"
#import "RMCircleAnnotation.h"
#import "RMCompositeSource.h"
#import "RMConfiguration.h"
#import "RMCoordinateGridSource.h"
... ...
//
// RMCircleAnnotation.h
// MapView
//
// Copyright (c) 2008-2013, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#import "RMShapeAnnotation.h"
/** An RMCircleAnnotation is a concrete subclass of RMShapeAnnotation that is used to represent a circle shape on the map. The annotation will automatically have a layer created when needed that displays an RMCircle.
*
* If you wish to customize the layer appearance in more detail, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMCircleAnnotation will not have any effect. */
@interface RMCircleAnnotation : RMShapeAnnotation
/** Initialize a circle annotation.
* @param aMapView The map view on which to place the annotation.
* @param centerCoordinate The center of the annotation.
* @param radiusInMeters The radius of the circle in projected meters.
* @return An initialized circle annotation object, or `nil` if an annotation was unable to be initialized. */
- (id)initWithMapView:(RMMapView *)aMapView centerCoordinate:(CLLocationCoordinate2D)centerCoordinate radiusInMeters:(CGFloat)radiusInMeters;
/** The circle annotation's center coordinate. */
@property (nonatomic, assign) CLLocationCoordinate2D centerCoordinate;
/** The circle annotation's line width. */
@property (nonatomic, assign) CGFloat lineWidthInPixels;
/** The radius of the circle annotation in projected meters. Regardless of map zoom, the circle will change visible size to continously represent this radius on the map. */
@property (nonatomic, assign) CGFloat radiusInMeters;
@end
... ...
//
// RMCircleAnnotation.m
// MapView
//
// Copyright (c) 2008-2013, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#import "RMCircleAnnotation.h"
#import "RMCircle.h"
@implementation RMCircleAnnotation
@synthesize radiusInMeters=_radiusInMeters;
- (id)initWithMapView:(RMMapView *)aMapView centerCoordinate:(CLLocationCoordinate2D)centerCoordinate radiusInMeters:(CGFloat)radiusInMeters
{
if (!(self = [super initWithMapView:aMapView points:[NSArray arrayWithObject:[[CLLocation alloc] initWithLatitude:centerCoordinate.latitude longitude:centerCoordinate.longitude]]]))
return nil;
_radiusInMeters = radiusInMeters;
return self;
}
- (void)setLayer:(RMMapLayer *)newLayer
{
if ( ! newLayer)
[super setLayer:nil];
else
RMLog(@"Setting a custom layer on an %@ is a no-op", [self class]);
}
- (RMMapLayer *)layer
{
if ( ! [super layer])
super.layer = [[RMCircle alloc] initWithView:self.mapView radiusInMeters:_radiusInMeters];
return [super layer];
}
- (CLLocationCoordinate2D)centerCoordinate
{
return self.coordinate;
}
- (void)setLineWidthInPixels:(CGFloat)lineWidthInPixels
{
[(RMCircle *)[self layer] setLineWidthInPixels:lineWidthInPixels];
}
- (CGFloat)lineWidthInPixels
{
return ((RMCircle *)[self layer]).lineWidthInPixels;
}
- (void)setLineWidth:(CGFloat)lineWidth
{
[self setLineWidthInPixels:lineWidth];
}
- (CGFloat)lineWidth
{
return [self lineWidthInPixels];
}
- (void)setRadiusInMeters:(CGFloat)radiusInMeters
{
[(RMCircle *)[self layer] setRadiusInMeters:radiusInMeters];
}
- (CGFloat)radiusInMeters
{
return [((RMCircle *)[self layer]) radiusInMeters];
}
@end
... ...
... ... @@ -112,6 +112,8 @@
DD5A200B15CAD09400FE4157 /* GRMustache.h in Headers */ = {isa = PBXBuildFile; fileRef = DD5A200A15CAD09400FE4157 /* GRMustache.h */; };
DD5FA1EB15E2B020004EB6C5 /* RMLoadingTileView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD5FA1E915E2B020004EB6C5 /* RMLoadingTileView.h */; settings = {ATTRIBUTES = (Private, ); }; };
DD5FA1EC15E2B020004EB6C5 /* RMLoadingTileView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD5FA1EA15E2B020004EB6C5 /* RMLoadingTileView.m */; };
DD63176317D15EB5008CA79B /* RMCircleAnnotation.h in Headers */ = {isa = PBXBuildFile; fileRef = DD63176117D15EB5008CA79B /* RMCircleAnnotation.h */; };
DD63176417D15EB5008CA79B /* RMCircleAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = DD63176217D15EB5008CA79B /* RMCircleAnnotation.m */; };
DD7C7E38164C894F0021CCA5 /* RMStaticMapView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7C7E36164C894F0021CCA5 /* RMStaticMapView.h */; settings = {ATTRIBUTES = (Public, ); }; };
DD7C7E39164C894F0021CCA5 /* RMStaticMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD7C7E37164C894F0021CCA5 /* RMStaticMapView.m */; };
DD8CDB4A14E0507100B73EB9 /* RMMapQuestOSMSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
... ... @@ -272,6 +274,8 @@
DD5A200A15CAD09400FE4157 /* GRMustache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GRMustache.h; path = GRMustache/include/GRMustache.h; sourceTree = "<group>"; };
DD5FA1E915E2B020004EB6C5 /* RMLoadingTileView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLoadingTileView.h; sourceTree = "<group>"; };
DD5FA1EA15E2B020004EB6C5 /* RMLoadingTileView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMLoadingTileView.m; sourceTree = "<group>"; };
DD63176117D15EB5008CA79B /* RMCircleAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMCircleAnnotation.h; sourceTree = "<group>"; };
DD63176217D15EB5008CA79B /* RMCircleAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMCircleAnnotation.m; sourceTree = "<group>"; };
DD6A83751644A20C0097F31F /* MapBox.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapBox.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
DD7C7E36164C894F0021CCA5 /* RMStaticMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMStaticMapView.h; sourceTree = "<group>"; };
DD7C7E37164C894F0021CCA5 /* RMStaticMapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMStaticMapView.m; sourceTree = "<group>"; };
... ... @@ -503,6 +507,8 @@
DDE357F316522661001DB842 /* RMPolylineAnnotation.m */,
DDE357F616522CD8001DB842 /* RMPolygonAnnotation.h */,
DDE357F716522CD8001DB842 /* RMPolygonAnnotation.m */,
DD63176117D15EB5008CA79B /* RMCircleAnnotation.h */,
DD63176217D15EB5008CA79B /* RMCircleAnnotation.m */,
16FAB66213E03D55002F4E1C /* RMQuadTree.h */,
16FAB66313E03D55002F4E1C /* RMQuadTree.m */,
B86F26AC0E87442C007A3773 /* RMMapLayer.h */,
... ... @@ -705,6 +711,7 @@
23A0AAEB0EB90AA6003A4521 /* RMFoundation.h in Headers */,
96492C400FA8AD3400EBA6D2 /* RMGlobalConstants.h in Headers */,
B1EB26C610B5D8E6009F8658 /* RMNotifications.h in Headers */,
DD63176317D15EB5008CA79B /* RMCircleAnnotation.h in Headers */,
D1437B37122869E400888DAE /* RMDBMapSource.h in Headers */,
1606C9FE13D86BA400547581 /* RMOpenCycleMapSource.h in Headers */,
16FAB66413E03D55002F4E1C /* RMQuadTree.h in Headers */,
... ... @@ -839,6 +846,7 @@
B8C974430E8A19B2007D16AD /* RMPixel.c in Sources */,
B8C974440E8A19B2007D16AD /* RMFractalTileProjection.m in Sources */,
B8C974480E8A19B2007D16AD /* RMTileCache.m in Sources */,
DD63176417D15EB5008CA79B /* RMCircleAnnotation.m in Sources */,
B8C9744A0E8A19B2007D16AD /* RMProjection.m in Sources */,
B8C9746C0E8A1A50007D16AD /* RMMapView.m in Sources */,
B8F3FC610EA2B382004D8F85 /* RMMapLayer.m in Sources */,
... ...