title: Google Maps simulate polyline with polygons
body: <p>I wrote a few years ago some code that highlighted a path on a Google Map with a user typed in width. The user determines how wide the highlighted path is in meters that way they can see the ground they have covered (ex lawn fertilizing etc). I calculated the distance from a point and used the Google Maps computeOffset to determine the corners of the polygon. Next I used the bearing information from the path to plot the next polygon.</p>
  
  <pre><code>LatLng corner1 = SphericalUtil.computeOffset(point2, widthInMeters / 2, bears + 90);
  LatLng corner2 = SphericalUtil.computeOffset(point2, widthInMeters / 2, bears - 90);
  LatLng corner3 = SphericalUtil.computeOffset(corner2, distance, bears);
  LatLng corner4 = SphericalUtil.computeOffset(corner1, distance, bears);
  
  return new PolygonOptions().add(corner1, corner2, corner3, corner4);
  </code></pre>
  
  <p>I did this because at the time the Google Maps SDK had no method of varying a polyline's width to show the width of navigated path. (ex farm implement so many feet wide.) The polyline feature to this day has constant width at different zoom levels.</p>
  
  <p><a href="https://i.stack.imgur.com/LZzNh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LZzNh.png" alt="Polygon mapping example at 50 feet wide"></a></p>
  
  <p>The problem is as you can see bearing information is very unreliable from a device especially if it is being shaken around. The path that is created makes gaps and the polygons don't smoothly connect like a thick polyline would.</p>
  
  <p>Has anyone seen any new APIs out there that have a way to highlight a path of certain width or an adjustable polyline (with spherical distance accounted for)? I thought about using smaller polygons with a higher count, but that is very resource intensive.</p>