Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Aug 20, 2020
2 parents ef34c97 + f41c625 commit bf1b30d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: hansemannn
8 changes: 8 additions & 0 deletions Classes/TiGooglemapsViewProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@
*/
- (NSNumber *)containsCoordinate:(id)annotation;

/**
* Returns the coordinate pair for the given point
*
* @return a dictionary with latitude and longitude
* @since 5.3.0
*/
- (NSDictionary *)coordinateForPoint:(id)value;

/**
* Returns the current map view zoom level.
*
Expand Down
12 changes: 12 additions & 0 deletions Classes/TiGooglemapsViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,18 @@ - (NSNumber *)containsCoordinate:(id)annotation
return @([bounds containsCoordinate:coordinate]);
}

- (NSDictionary *)coordinateForPoint:(id)value
{
ENSURE_SINGLE_ARG(value, NSDictionary);

CGPoint point = [TiUtils pointValue:value];
CLLocationCoordinate2D coordinate = [[self mapView].mapView.projection coordinateForPoint:point];
return @{
@"latitude" : @(coordinate.latitude),
@"longitude" : @(coordinate.longitude)
};
}

- (void)showAnnotations:(id)args
{
ENSURE_UI_THREAD(showAnnotations, args);
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,17 @@ const location2 = { latitude: 52.279911, longitude: 8.047179 };
const geometryDistanceBetweenPoints = maps.geometryDistanceBetweenPoints(location1, location2);
```

#### `coordinateForPoint`

Returns the coordinate pair for the given screen point

```js
const coordinate = maps.coordinateForPoint({
x: point.x,
y: point.y,
});
```

### Google License Info

Google requires you to link the Open Source license somewhere in your app.
Expand Down

0 comments on commit bf1b30d

Please sign in to comment.