Hi Kenneth,
I used to use Google, but switched to Mapquest for this kind of thing.
Below is a bit of code I hope you find useful. You still need an API key
but its easy to obtain, and there is no charge for light usage.
async function mapquest(){
//This function is used to calculate Travel Time & Miles to Jobsite
//https://developer.mapquest.com/forum/i-only-need-miles
//There is an info.statusCode and info.messages node that will give
details about any known failure.
{{#Embedded Python}}
{{if cust_addr_rec.CITY and cust_addr_rec.STATE:}}
let url =
'https://www.mapquestapi.com/directions/v2/routematrix?json={"locations":["Richfield,
PA","{{=cust_addr_rec.CITY}},
{{=cust_addr_rec.STATE}}"]}&outFormat=json&key='enter-your-api-key-here';
let obj = null;
try {
obj = await (await fetch(url)).json();
document.querySelector("#FLD_MILES").innerHTML =
('Miles:'+(obj.distance[1]).toFixed(0)+'
Hrs:'+(obj.time[1]/3600).toFixed(2));
document.querySelector("#FLD_MILES").focus();
document.querySelector("#FLD_MILES").blur();
} catch(e) {
document.querySelector("#FLD_MILES").innerHTML =
('error:'+e);
console.log('error');
console.log(e);
}
{{pass}}
}
-Rob
On Friday, March 11, 2022 at 2:30:12 PM UTC-5 Kenneth wrote:
> Hello,
>
> has anybody used Google Maps after 2018, looks like you need an api key to
> use the geocode function. Geocode doesn't seam to be updated for this?
>
>
> Kenneth
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/d5da8399-556a-49fd-adc9-f9955287c8a3n%40googlegroups.com.