the.wizard
the.wizard

Reputation: 1109

How to detect or check whether a Poly Line was Inside Another Poly Line or Overlap with Other Poly Line Using Google Maps

I was using Google Maps Javascript API (GWT Maps V3 API) to some poly line in Google Maps. There are some poly line that overlap each other like in this picture: Two Poly Line overlap

As we can see from the picture above, there are two poly line blue and purple that overlap each other (they have the same path). Then add a red poly line among those two poly line like this: Three poly line overlap

Now I need to get all poly line that overlap / intersect with the red poly line. Is there any way I could do this in Google Maps Javascript API? Any comment and answer will be appreciated. Thanks and regards.

Upvotes: 2

Views: 2299

Answers (1)

Verma
Verma

Reputation: 8439

You could use geometry library

isLocationOnEdge(point:LatLng, poly:Polygon|Polyline, tolerance?:number)

To determine whether a point falls on or near a polyline, or on or near the edge of a polygon, pass the point, the polyline/polygon, and optionally a tolerance value in degrees to google.maps.geometry.poly.isLocationOnEdge(). The function returns true if the distance between the point and the closest point on the line or edge falls within the specified tolerance. The default tolerance value is 10-9 degrees.

Upvotes: 4

Related Questions