feat: (broken) implement route map and address autocomplete widgets with associated infrastructure testing scripts
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const axios = require('axios');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function testSteps() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Toulouse, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.legs.steps.navigationInstruction,routes.legs.steps.distanceMeters,routes.legs.steps.startLocation,routes.legs.steps.endLocation' } });
|
||||
|
||||
const steps = resToll.data.routes[0].legs[0].steps;
|
||||
for(let i=0; i<steps.length; i++) {
|
||||
const step = steps[i];
|
||||
const inst = step.navigationInstruction ? step.navigationInstruction.instructions : '';
|
||||
if(inst.toLowerCase().includes('péage') || inst.toLowerCase().includes('toll')) {
|
||||
console.log(`Step ${i}: ${inst} (Dist: ${step.distanceMeters}m)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
testSteps();
|
||||
Reference in New Issue
Block a user