containsLocation() Polyline in Polygon - google-maps

Is there a possibilty to check that Polyline is in Polygon? Or I must check each points in Polyline containsLocation in Polygon?
I think about importing gpx files (my Polyline) and check what administrative area (my Polygons) contains this Polyline. I was thinking about reverse geocoding for each points in Polyline, but its impossible due to geocoding limitations. Any ideas?

You have to check every point of the Polyline against your Polygon. Take into account that a Polyline can be (according to DE-9IM):
Within your polygon (contained) = completely contained
Intersect your polygon = partially contained
Disjoint = not contained
So, a polyline can intersect two different Polygons (your Polyline can intersect two different administrative areas)

Related

Big polyline and big polygon intersection

Working with the Google Maps API, I want to compute the intersection of a polyline and a polygon. I recall that polyline and polygon are sets of consecutive segments, the only difference is that a polygon is closed.
My first guess would be to check if any segment of the polyline intersects with any segment of the polygon. However my polylines can have up to 1e4 segments and my polygons up to 1e5 segments. Testing every pair would be too long.
Any idea of how to do that in a smarter way?

Google map api - V3 Distance between two polygons

On one project , I recovered all the coordinates of the polygons of different postal code.
When I search a zip code, I draw the polygon using the google api.
Now I would like to know whether a given polygon is so much distance from another .
Is that possible ?
By parsing all my geojson , I need to know if a random polygon is 5km from the polygon drawn .
There is computeDistanceBetween method from the geometry library...but its for two points. Is there the same for the distance between two polygons ?
Thx u for your help
Not sure if this would solve your problem but you can somehow use this library to compute distances within your polygon.
BDCCgeo.js
There is a function called bdccGeoDistanceToPolyMtrs(), you can measure the distance between a point and a polygon edge or polyline. Perhaps you can get a certain point on your first polygon and compare with with the second using this function.
Reference:
Distance from point within a polygon to polygon edge

What are the differences between using routes (direction service) and using polyline with Google Maps API?

I read in the documentation that using polyline, I just have a straight line between two points. And if I use Routes (direction service), I don't have the straight line, but a real route between this two places (points).
Not exactly. Polyline means you give a list (array) of points; the polyline follows those points (with a straight line from one point to the next).
If you only give the start and end point, then yes, it will be a straight line (still following the curve of the earth).
You can request a route, read the waypoints of the route and make (draw) a polyline that follows the exact route.
The only reason you would do this, is because you have much more control over the polyline than over the standard route that Google draws.
Example: with a polyline, you can easily set onClick events on that polyline; it's a harder to do this with the standard route

Get latitude and longitude points in Google Maps polyline

I want to draw Polylines with the Google Maps JavaScript API. Is there a tool that will help me get the latitude and longitude points by just clicking on the map, then exporting an array of lat-long pairs?
I imagine something like the personalized maps service (My Places) in Google Maps where you can click-snap on the roads to specify your own driving directions. I'd like to take that one step further. That is, to export an array of lat-long pairs that specify the roads traveled.
I know this answer might be a little late but today I was trying to figure out what I believe to be the same issue as this question. So, you can draw the points on the map then get that encoded polyline with Google's Interactive Polyline Encoder Utility then I recommend using Mapbox polyline utility to convert the overview_polyline to latitude and longitude pairs values. The latitude and longitude pairs are also on Googles Utility but it is a bit of a hassle to continuously copy each coordinate.
For more information about the Mapbox Polyline Utility process:
http://zevross.com/blog/2014/09/23/convert-google-directions-to-geojson-points-or-polylines/
And here is Google's Encoder Utility:
https://developers.google.com/maps/documentation/utilities/polylineutility
You can use the Drawing Tools library:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#drawing_tools
which will give you an encoded polyline. You can use that to draw a line, or you can decode it to get the specific points using the geometry library:
http://code.google.com/apis/maps/documentation/javascript/geometry.html

How to obtain suburb's polygon?

Is it possible to obtain through geocoding service polygon not a single point on map?
You can define your suburb in the form of a kml polygon. To do this you will need to know the points that form the boundary of this suburb.