0

I have drawn a polygon on google map(with certain lats and lngs) now I would like to grow the outer of this polygon by 40 meters(input from users). How can I achieve this? Thank you enter image description here

Thank you @geocodezip, I tried buffering polygon data(without using center point of polygon) and got this enter image description here

distance between black and red lines seems not same.

Thanks for all replies && answers! I found a way to do that without buffering polygon/polylines data. Should have a better way to do this. But I would like to share what I have done in here:

  1. I know two gps points: A and B so I could get bearing between those two points.
  2. Based on this bearing I could get the bearing between A and the point(C) 40 meters away from A because line between A and C is 90 degrees against the line between A and B
  3. With the new bearing and distance(40m) I could get the gps point of C (How to calculate the latlng of a point a certain distance away from another?)
  4. finally do step from 1~3 again with point from B to A

Here is a screenshot of what I have done (I have not finish yet, will upload a final screenshot later.) enter image description here

Community
  • 1
  • 1
bf39L
  • 149
  • 2
  • 14
  • I found a link about growing/shrinking polygon but don't know how that could help my problem: http://codepen.io/HansMuller/pen/lDfzt – bf39L Apr 06 '16 at 23:35
  • possible duplicate of [Add some area in polygon (JavaScript::Google Map API v3)](http://stackoverflow.com/questions/27089944/add-some-area-in-polygon-javascript-google-map-api-v3) – geocodezip Apr 06 '16 at 23:50
  • I tried the buffering polygon data without using the centre point. but realise the distance is not accurate. – bf39L Apr 07 '16 at 02:35
  • Perhaps you could provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) of your polygon. – geocodezip Apr 07 '16 at 03:17

2 Answers2

0
  1. Draw lines parallel to the existing ones 40 meters (or whatever the desired buffer is) to either side.
  2. Remove the ones that have either endpoint inside the polygon
  3. Extend the new lines and find their intersections
  4. The intersections define the new "bigger" polygon.
geocodezip
  • 158,664
  • 13
  • 220
  • 245
0

Finally got this problem solved, not perfect I know.XD

enter image description here

Implement lines intersection: from here ( [http://jsfiddle.net/justin_c_rounds/Gd2S2/])

enter image description here

bf39L
  • 149
  • 2
  • 14