get lying longitude and latitude from current boun

2019-08-28 00:30发布

问题:

I am working to get Instagram results from a shape drawn on a map. Instagram needs lat and lon + radius.

https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&access_token=ACCESS-TOKEN

What my issue is I can do this if I use circle but for rectangle I am not getting what to send to api.

My image/ map plus rectangle.

If I use getBounds(); Then I get

_northEast

    Object { lat=33.97980872872457, lng=-82.166748046875, equals=function(), more...}

_southWest

    Object { lat=33.568861182555565, lng=-83.5565185546875, equals=function(), more...}

But Api needs only one lat and lon. So can some one help what to send to api in this case?

回答1:

Based on the Instagram API, you can ONLY send a circle. The closes equivalent would be send the smallest enclosing circle

With the Maps API, I would take a shortcut and use the following algorithim:

  • Use getBounds().getCenter() to get the center LatLng of your rectangle. This is your LatLng.
  • Use the computeDistanceBetween method of the geometry library along with either of the points from the original getBounds() call to calculate your radius.


回答2:

GMSGeometryContainsLocation(coordinate, rect, true) will work for this. Pass the object of CLLocationCoordinate2D as coordinate and and GMSPath as rect. It give Bool value. Thanks