Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vfp9 get data from google maps 1

Status
Not open for further replies.

stardemos

Technical User
Jan 30, 2017
8
PT
hello, i'm new to vfp,and i'm loving it.
Anyway, i have a questin, i nedd to get the distance from gogle maps, it´s that possible? how?
for better undestanding of the question, this is part of my code.
Code:
Do ydeclare

Local m.yfrom,m.yto
m.yfrom=Inputbox("Origem","",lcTextO)
m.yto=Inputbox("Destino","",m.lctext)

If Empty(m.yfrom) Or Empty(m.yto)
    Return .F.
Else
	m.yfrom=Allt(Strtran(m.yfrom," ","-"))
	m.yto=Allt(Strtran(m.yto," ","-"))
Endi
Local m.url
m.url="[URL unfurl="true"]https://www.google.pt/maps/dir/"+m.yfrom+"/"+m.yto[/URL]
_Cliptext=m.url  &&url in clipboard
Local apie
apie= Createobject("wscript.shell")
apie.Run(m.Url)
Procedure ydeclare
Declare Integer BringWindowToTop In user32 Integer
Declare Integer SetWindowText In user32 Integer,String
Declare Integer Sleep In kernel32 Integer
Endproc

this give me the best ways to get to my clients, now i nedd to get the distance from the google maps. and insert it in my db.
 
Welcome to the forum, and to VFP.

The best way to solve your problem is probably to use the Google Maps API. Calculating distances between two points is one of the things it was invented for.

For general information about the API, see
For specific details about getting distances between locations:
I suggest you start with that, then come back if you have any questions about how to do it in VFP.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Stardemos
If you need help I have develloped a full version of multiple waypoints with distance between waypoints and a feature that optimizes the route. Post back here if you want help.




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
hello, i have been trying to read the xml, without any success, the xml opens in the browser with the data that i need, i just dont know how to get the data.... any help will be apreciated.
 
Hi,
Distance from address1 to address2.
Which distance? a) straight line (air distance) or b) road distance ?
For each Google has a solution to be implented into VFP
Regards,
Jockey(2)
 
Yes, the documentation we pointed to covers that topic, too. Default distance is computed for a car, so taking roads into account, and resulting in no result, if you pass in locations parted by an ocean. You can change the travel modus parameter from pedestrian up to airplane, I think. Well, it's all in the google developer documentation. Somehow there surely is a danger of computing a route with one API and a distance with another, when the two systems don't share the same route.

Perhaps take Mike Gagnons offer? He seems to have already delved deeper into these APIs.

Bye, Olaf.

 
Distance from address1 to address2.
Which distance? a) straight line (air distance) or b) road distance ?
For each Google has a solution to be implented into VFP

You are right, but doesn't the API takes care of all that?

Of course, if it was simply a straight-line distance, you might not need Google maps or any other on-line tool; it could be a simple bit of trigonomotry (depending on the country).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You might want to try Bing Maps, which is a more complete API with less restrictions, which depending what you want to do, may give you a result like this.

Screenshot_-_2017-02-15_12_30_33_PM_lqgjlt.png


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
maybe its a good idea to try it, can you show some samples of your code?


maybe its better to explain myself even better about this project of a program, it must be integrated insid another software develope in foxpro, so i can´t depend on .dll or .fll because i cant access them. by the way, all of other ideas seem to work fine in pure vfp.
 
What do you mean, you can't access a dll or fll? FLL are foxpro link libraries, DLLs specifically aimed for being used in Foxpro via SET LIBRARY TO some.fll
DLLs can be used by DECLAREs, typically. Or if it's assemblies by wwDotNetBridge.

But who pointed you to a DLL, yet?

Bye, Olaf.
 
On which Windows version are you? CreateObject("Microsoft.XMLHTTP") should work from Windows 98 to 10 - all the way.
Besides that, the VFPConnection.FLL has a nice and easy interface to do both HTTP get and post requests, too including FTP/FTPS, when you may need it later, too.

Bye, Olaf.
 
im on win 10, but this code is running under another software, PHC management software. thats the reason why i can use dll files, until now. i believe thats possible.
 
Microsoft.XMLHTTP is a COM Server, you only use the MSXML DLL indirectly. You can only use CreateObject() in VFP. If this software is allowing you to execute VFP macros/scripts but only supports a partial set of commands and functions, that might be a reason, but as you get a concrete message about msxml3.dll missing, your system seems somewhat broken in respect of system components, not about VFP or PHC. MSXML is deep in the system. I have Microsoft.XMLHTTP available on Windows 10, not only in VFP, also from powershell, for example:

posh_qdrnt5.png

If that errors, too, you know you have a problem on the system, neither in VFP, nor PHC, but in your Windows.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top