Skip to content Skip to sidebar Skip to footer

Make Polygons Perpendicular To Bearing In Google Maps Android

I'm creating polygons on a map getMap().addPolygon( getPolygonOptions(point1, point2, widthInMeters) .fillColor(Color.YELLOW)); The position of th

Solution 1:

It may be problem of units which are returning from two functions.

Here, SphericalUtil.computeDistanceBetween(point1, point2) returns the values in meters.

and

Google's location documentation suggests,

location.getBearing() returns values in degrees.

Get the bearing, in degrees. Bearing is the horizontal direction of travel of this device, and is not related to the device orientation. It is guaranteed to be in the range (0.0, 360.0] if the device has a bearing.

If this location does not have a bearing then 0.0 is returned.

Please, check whether the location is heaving bearing pr not before using location.getBearing()

So, you have convert those degrees into meters and then implement it in your logic. It will solve your issue.

Post a Comment for "Make Polygons Perpendicular To Bearing In Google Maps Android"