2021年1月15日星期五

Is there an optimal way to save money by drawing routes with polylines with the Directions API in real time?

I am planning to build an android app from scratch like uber with Android Studio and Java. I did a similar project before (over 1 year ago), so I will use some of the code from the old project to explain the way I was drawing the polylines.

I used this classic method, to draw polylines after obtaining the path:

for (int i = 0; i < routes.size(); i++) {      Route route = routes.get(i);      if(polyline_path != null){          polyline_path.setPoints(route.points);      }  }  

I currently make a request to the Directions API every time the user moves with LocationListener.onLocationChanged(), but I know it is not optimal (at least for making a lot of requests in the directions API). So can I get the route only once with the directions API and then redraw the polyline without needing to request the API again?

Or any ideas how Uber or similar platforms do this?

https://stackoverflow.com/questions/65746097/is-there-an-optimal-way-to-save-money-by-drawing-routes-with-polylines-with-the January 16, 2021 at 11:05AM

没有评论:

发表评论