Это можно сделать также с помощью намерений:
final Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(
"http://maps.google.com/maps?" +
"saddr="+YOUR_START_LONGITUDE+","+YOUR_START_LATITUDE+"&daddr="YOUR_END_LONGITUDE+","+YOUR_END_LATITUDE));
intent.setClassName(
"com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
Ваши запросы истекают из-за того, что вы заполняете сервер слишком большим количеством запросов. Вы должны разбить ваши многочисленные запросы на меньшие партии и ждать их.
Вот как это будет работать с API fetch
:
async function getall() {
const ops = [];
const length = 50; // reduced for snippet reasons ... :)
const batchsize = 10;
for (let x = 0; x < length; x+=batchsize) {
const batch = [];
for (let y = x; y < length && y < x + batchsize; y++) {
const req = fetch("https://jsonplaceholder.typicode.com/todos/1")
.then((resp) => resp.json());
batch.push(req);
}
// Wait for this batch to be completed before launching the next batch:
ops.push(...await Promise.all(batch));
}
return ops;
}
getall().then((res) => console.log(res));