/MapView/Map/RMMarker.h

http://github.com/route-me/route-me · C Header · 92 lines · 37 code · 14 blank · 41 comment · 0 complexity · e5a1b1a05ab3700f04a6b314867bad8a MD5 · raw file

  1. //
  2. // RMMarker.h
  3. //
  4. // Copyright (c) 2008-2009, Route-Me Contributors
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are met:
  9. //
  10. // * Redistributions of source code must retain the above copyright notice, this
  11. // list of conditions and the following disclaimer.
  12. // * Redistributions in binary form must reproduce the above copyright notice,
  13. // this list of conditions and the following disclaimer in the documentation
  14. // and/or other materials provided with the distribution.
  15. //
  16. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  20. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  24. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  26. // POSSIBILITY OF SUCH DAMAGE.
  27. #import <UIKit/UIKit.h>
  28. #import "RMMapLayer.h"
  29. #import "RMFoundation.h"
  30. #ifdef DEBUG
  31. #import <CoreLocation/CoreLocation.h>
  32. #endif
  33. @class RMMarkerStyle;
  34. /// one marker drawn on the map. Note that RMMarker ultimately descends from CALayer, and has an image contents.
  35. /// RMMarker inherits "position" and "anchorPoint" from CALayer.
  36. @interface RMMarker : RMMapLayer <RMMovingMapLayer> {
  37. /// expressed in projected meters. The anchorPoint of the image is plotted here.
  38. RMProjectedPoint projectedLocation;
  39. /// provided for storage of arbitrary user data
  40. NSObject* data;
  41. /// Text label, visible by default if it has content, but not required.
  42. UIView *label;
  43. UIColor *textForegroundColor;
  44. UIColor *textBackgroundColor;
  45. BOOL enableDragging;
  46. BOOL enableRotation;
  47. }
  48. @property (assign, nonatomic) RMProjectedPoint projectedLocation;
  49. @property (assign) BOOL enableDragging;
  50. @property (assign) BOOL enableRotation;
  51. @property (nonatomic, retain) NSObject* data;
  52. @property (nonatomic, retain) UIView* label;
  53. @property(nonatomic,retain) UIColor *textForegroundColor;
  54. @property(nonatomic,retain) UIColor *textBackgroundColor;
  55. /// the font used for labels when another font is not explicitly requested; currently [UIFont systemFontOfSize:15]
  56. + (UIFont *)defaultFont;
  57. /// returns RMMarker initialized with #image, and the default anchor point (0.5, 0.5)
  58. - (id) initWithUIImage: (UIImage*) image;
  59. /// \brief returns RMMarker initialized with provided image and anchorPoint.
  60. /// #anchorPoint x and y range from 0 to 1, normalized to the width and height of image,
  61. /// referenced to upper left corner, y increasing top to bottom. To put the image's upper right corner on the marker's
  62. /// #projectedLocation, use an anchor point of (1.0, 0.0);
  63. - (id) initWithUIImage: (UIImage*) image anchorPoint: (CGPoint) anchorPoint;
  64. /// changes the labelView to a UILabel with supplied #text and default marker font, using existing text foreground/background color.
  65. - (void) changeLabelUsingText: (NSString*)text;
  66. /// changes the labelView to a UILabel with supplied #text and default marker font, positioning the text some weird way i don't understand yet. Uses existing text color/background color.
  67. - (void) changeLabelUsingText: (NSString*)text position:(CGPoint)position;
  68. /// changes the labelView to a UILabel with supplied #text and default marker font, changing this marker's text foreground/background colors for this and future text strings.
  69. - (void) changeLabelUsingText: (NSString*)text font:(UIFont*)font foregroundColor:(UIColor*)textColor backgroundColor:(UIColor*)backgroundColor;
  70. /// changes the labelView to a UILabel with supplied #text and default marker font, changing this marker's text foreground/background colors for this and future text strings; modifies position as in #changeLabelUsingText:position.
  71. - (void) changeLabelUsingText: (NSString*)text position:(CGPoint)position font:(UIFont*)font foregroundColor:(UIColor*)textColor backgroundColor:(UIColor*)backgroundColor;
  72. - (void) toggleLabel;
  73. - (void) showLabel;
  74. - (void) hideLabel;
  75. - (void) replaceUIImage:(UIImage*)image;
  76. - (void) replaceUIImage:(UIImage*)image anchorPoint:(CGPoint)anchorPoint;
  77. - (void) dealloc;
  78. @end