Skip to content

Commit

Permalink
Merge pull request react-native-maps#734 from Mobeye/fix/google_maps_…
Browse files Browse the repository at this point in the history
…ios_anchor

Fix Anchor point on Google Maps iOS
  • Loading branch information
Spike Brehm authored Oct 27, 2016
2 parents 2486841 + 561234a commit 1179441
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/marker.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
| `image` | `ImageSource` | | A custom image to be used as the marker's icon. Only local image resources are allowed to be used.
| `pinColor` | `Color` | | If no custom marker view or custom image is provided, the platform default pin will be used, which can be customized by this color. Ignored if a custom marker is being used.
| `coordinate` | `LatLng` | | The coordinate for the marker.
| `centerOffset` | `Point` | | The offset (in points) at which to display the view.<br/><br/> By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in points. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.<br/><br/> For android, see the `anchor` prop.
| `centerOffset` | `Point` | | The offset (in points) at which to display the view.<br/><br/> By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in points. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.<br/><br/> For Google Maps, see the `anchor` prop.
| `calloutOffset` | `Point` | | The offset (in points) at which to place the callout bubble.<br/><br/> This property determines the additional distance by which to move the callout bubble. When this property is set to (0, 0), the anchor point of the callout bubble is placed on the top-center point of the marker view’s frame. Specifying positive offset values moves the callout bubble down and to the right, while specifying negative values moves it up and to the left.<br/><br/> For android, see the `calloutAnchor` prop.
| `anchor` | `Point` | | Sets the anchor point for the marker.<br/><br/> The anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface.<br/><br/> The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner. The anchoring point in a W x H image is the nearest discrete grid point in a (W + 1) x (H + 1) grid, obtained by scaling the then rounding. For example, in a 4 x 2 image, the anchor point (0.7, 0.6) resolves to the grid point at (3, 1).<br/><br/> For ios, see the `centerOffset` prop.
| `anchor` | `Point` | | Sets the anchor point for the marker.<br/><br/> The anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface.<br/><br/> The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner. The anchoring point in a W x H image is the nearest discrete grid point in a (W + 1) x (H + 1) grid, obtained by scaling the then rounding. For example, in a 4 x 2 image, the anchor point (0.7, 0.6) resolves to the grid point at (3, 1).<br/><br/> For MapKit on iOS, see the `centerOffset` prop.
| `calloutAnchor` | `Point` | | Specifies the point in the marker image at which to anchor the callout when it is displayed. This is specified in the same coordinate system as the anchor. See the `anchor` prop for more details.<br/><br/> The default is the top middle of the image.<br/><br/> For ios, see the `calloutOffset` prop.
| `flat` | `Boolean` | | Sets whether this marker should be flat against the map true or a billboard facing the camera false.
| `identifier` | `String` | | An identifier used to reference this marker at a later date.
Expand Down
1 change: 1 addition & 0 deletions ios/AirGoogleMaps/AIRGoogleMapMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, strong) UIColor *pinColor;
@property (nonatomic, assign) CGPoint anchor;
@property (nonatomic, assign) NSInteger zIndex;
@property (nonatomic, assign) BOOL draggable;

Expand Down
9 changes: 6 additions & 3 deletions ios/AirGoogleMaps/AIRGoogleMapMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ - (void)setImageSrc:(NSString *)imageSrc

_iconImageView = imageView;
[self iconViewInsertSubview:imageView atIndex:0];

// TODO: This could be a prop
//_realMarker.groundAnchor = CGPointMake(0.75, 1);
});
}];
}
Expand All @@ -253,6 +250,12 @@ - (void)setPinColor:(UIColor *)pinColor {
_realMarker.icon = [GMSMarker markerImageWithColor:pinColor];
}

- (void)setAnchor:(CGPoint)anchor {
_anchor = anchor;
_realMarker.groundAnchor = anchor;
}


- (void)setZIndex:(NSInteger)zIndex
{
_zIndex = zIndex;
Expand Down
1 change: 1 addition & 0 deletions ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(title, NSString)
RCT_REMAP_VIEW_PROPERTY(description, subtitle, NSString)
RCT_EXPORT_VIEW_PROPERTY(pinColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(anchor, CGPoint)
RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTDirectEventBlock)
Expand Down

0 comments on commit 1179441

Please sign in to comment.