Skip to content Skip to sidebar Skip to footer

Find The Total Distance Of A Polyline Segment Within A Polygon

I have a map which will consist of multiple 'zones', each of which are created as polygon overlays. I also allow a user to define a route and using the DirectionsService, I render

Solution 1:

depending on what distance increment you're using (feet, meters, km, miles), here's what I'd do...

varincrement=0;
varzone= initial_zone;

//loop structureif(currentzone== zone){
   increment = increment + 1;
}
else{
    zone = zone_2;
}

etc...etc

Solution 2:

  • Search for line polygon intersection
  • pick an algorithm you understand or find an implementation in javascript you can port to the API
  • use it to find the intersections of your route with your polygons
  • use the geometry library to determine the length of the segments inside each polygon

Post a Comment for "Find The Total Distance Of A Polyline Segment Within A Polygon"