HI, someone has an sample to trace rotes in google maps? very thanks
HI, someone has an sample to trace rotes in google maps? very thanks
Hi,
Theres a simple google map link generator that can generate a route in google maps on xharbour.com community pages if you have access to that.
Regards,
Pete
Pete, you have an link for community? thanks
Function MakeMMapa()
Local cDp,cDir1,cTipoVia,cCiudad,cNum:=""
Local cDpd,cDir1d,cTipoViad,cCiudadd,cNumd:=""
Local cHttp:="http://maps.google.es/maps?f=q&hl=es&q="
Local aArrai:={"Ruta","Recogida"},nAlert:=0
Local ccDir1,ccDp,ccCiudad
Local cTo2:="",cTo3:="",cTo4:="",cTo5:="",cTo6:=""
//http://maps.google.es/maps?f=d&hl=es&geocode=&saddr=CALLE+DE+ORENSE++12+28020+MADRID&daddr=CALLE+DE+ALABASTRO++12+28224+POZUELO+DE+ALARCON+to:oviedo,+2+madrid&mra=pi&mrcr=1&sll=40.449915,-3.74632&sspn=0.065445,0.124626&ie=UTF8&z=13&om=1
//http://maps.google.es/maps?f=d&hl=es&geocode=&saddr=CALLE+DE+ORENSE++12+28020+MADRID&daddr=CALLE+DE+ALABASTRO++12+28224+POZUELO+DE+ALARCON+
//to:oviedo,+2+madrid+to:alcala,+20+madrid&mra=pi&mrcr=2&sll=40.449915,-3.74632&sspn=0.065445,0.124626&ie=UTF8&ll=40.449915,-3.74632&spn=0.130891,0.249252
//&z=12&om=1
IF !EMPTY(_ALIAS->DIR2+_ALIAS->CIUDAD2)
AADD(aArrai,"Punto 1")
cDp:=_ALIAS->DP2
cCiudad:=_ALIAS->CIUDAD2
cDir1:=_ALIAS->DIR2
BUSCACITY(@cDir1,@cNum,@cTipoVia,cDp,cCiudad)
cTo2:="+to:"+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
ENDIF
IF !EMPTY(_ALIAS->DIR3+_ALIAS->CIUDAD3)
AADD(aArrai,"Punto 2")
cDp:=_ALIAS->DP3
cCiudad:=_ALIAS->CIUDAD3
cDir1:=_ALIAS->DIR3
BUSCACITY(@cDir1,@cNum,@cTipoVia,cDp,cCiudad)
cTo3:="+to:"+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
ENDIF
IF !EMPTY(_ALIAS->DIR4+_ALIAS->CIUDAD4)
AADD(aArrai,"Punto 3")
cDp:=_ALIAS->DP4
cCiudad:=_ALIAS->CIUDAD4
cDir1:=_ALIAS->DIR4
BUSCACITY(@cDir1,@cNum,@cTipoVia,cDp,cCiudad)
cTo4:="+to:"+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
ENDIF
IF !EMPTY(_ALIAS->DIR5+_ALIAS->CIUDAD5)
AADD(aArrai,"Punto 4")
cDp:=_ALIAS->DP5
cCiudad:=_ALIAS->CIUDAD5
cDir1:=_ALIAS->DIR5
BUSCACITY(@cDir1,@cNum,@cTipoVia,cDp,cCiudad)
cTo5:="+to:"+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
ENDIF
IF !EMPTY(_ALIAS->DIR6+_ALIAS->CIUDAD6)
AADD(aArrai,"Punto 5")
cDp:=_ALIAS->DP6
cCiudad:=_ALIAS->CIUDAD6
cDir1:=_ALIAS->DIR6
BUSCACITY(@cDir1,@cNum,@cTipoVia,cDp,cCiudad)
cTo6:="+to:"+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
ENDIF
nAlert:=ALERT("Localiza",aArrai,"Mapas")
IF nAlert=0
RETURN NIL
ENDIF
DO CASE
CASE nAlert=1
cDp:=TRIM(_ALIAS->DP)
cCiudad:=TRIM(_ALIAS->CIUDAD)
cDir1:=_ALIAS->DIR1
cDpd:=TRIM(_ALIAS->DP2)
cCiudadd:=TRIM(_ALIAS->CIUDAD2)
cDir1d:=_ALIAS->DIR2
CASE nAlert=2
cDp:=TRIM(_ALIAS->DP)
cCiudad:=TRIM(_ALIAS->CIUDAD)
cDir1:=_ALIAS->DIR1
CASE nAlert=3
cDp:=TRIM(_ALIAS->DP2)
cCiudad:=TRIM(_ALIAS->CIUDAD2)
cDir1:=_ALIAS->DIR2
CASE nAlert=4
cDp:=TRIM(_ALIAS->DP3)
cCiudad:=TRIM(_ALIAS->CIUDAD3)
cDir1:=_ALIAS->DIR3
CASE nAlert=5
cDp:=TRIM(_ALIAS->DP4)
cCiudad:=TRIM(_ALIAS->CIUDAD4)
cDir1:=_ALIAS->DIR4
CASE nAlert=6
cDp:=TRIM(_ALIAS->DP5)
cCiudad:=TRIM(_ALIAS->CIUDAD5)
cDir1:=_ALIAS->DIR5
CASE nAlert=7
cDp:=TRIM(_ALIAS->DP6)
cCiudad:=TRIM(_ALIAS->CIUDAD6)
cDir1:=_ALIAS->DIR6
ENDCASE
BUSCACITY(@cDir1,@cNum,@cTipoVia,cDp,cCiudad)
IF nAlert=1
BUSCACITY(@cDir1d,@cNumd,@cTipoViad,cDpd,cCiudadd)
//cHttp:=cHttp+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
//http://maps.google.es/maps?f=d&hl=es&geocode=&saddr=CALLE+DE+ORENSE++12+28020+MADRID&daddr=CALLE+DE+ALABASTRO++12+28224+POZUELO+DE+ALARCON+
cHttp:="http://maps.google.es/maps?f=d&hl=es&geocode=&saddr="+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad+"&daddr="+cTipoViad+cDir1d+"+"+cNumd+"+"+cDpd+"+"+cCiudadd+cTo3+cTo4+cTo5+cTo6
ELSE
cHttp:=cHttp+cTipoVia+cDir1+"+"+cNum+"+"+cDp+"+"+cCiudad
ENDIF
SHELLEXECUTE(0,0,cHttp,0,0,1)
RETURN NIL
***********************************************************************
FUNCTION BUSCACITY(cDir1,cNum,cTipoVia,cDp,cCiudad)
Local i,j:=0
cDir1:=TRIM(cDir1)
cDp:=TRIM(cDp)
cCiudad:=TRIM(cCiudad)
DO CASE
CASE SUBSTR(cDir1,1,10)="AVENIDA DE"
cTipoVia:="AVENIDA+DE "
cDir1:=SUBSTR(cDir1,11)
CASE SUBSTR(cDIR1,1,4)="AV. "
cTipoVia:="AVENIDA DE "
cDir1:=SUBSTR(cDir1,5)
CASE SUBSTR(cDir1,8)="AV DE LA"
cTipoVia:="AVENIDA DE "
cDir1:=SUBSTR(cDir1,10)
CASE SUBSTR(cDir1,09)="AV DE LAS"
cTipoVia:="AVENIDA DE LAS "
cDir1:=SUBSTR(cDir1,11)
CASE SUBSTR(cDir1,09)="AV DE LOS"
cTipoVia:="AVENIDA DE LOS"
cDir1:=SUBSTR(cDir1,10)
CASE SUBSTR(cDir1,06)="AV DEL"
cTipoVia:="AVENIDA DEL"
cDir1:=SUBSTR(cDir1,08)
CASE SUBSTR(cDir1,03)="AV "
cTipoVia:="AVENIDA"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="AV,"
cTipoVia:="AVENIDA"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="AV."
cTipoVia:="AVENIDA"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,06)="AV.DE "
cTipoVia:="AVENIDA"
cDir1:=SUBSTR(cDir1,07)
CASE SUBSTR(cDir1,04)="AVD "
cTipoVia:="AVENIDA"
cDir1:=SUBSTR(cDir1,05)
CASE SUBSTR(cDir1,04)="AVD."
cTipoVia:="AVENIDA"
cDir1:=SUBSTR(cDir1,05)
CASE SUBSTR(cDir1,03)="P§ "
cTipoVia:="PASEO"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="PSO "
cTipoVia:="PASEO"
cDir1:=SUBSTR(cDir1,05)
CASE SUBSTR(cDir1,02)="PS "
cTipoVia:="PASEO"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,06)="PQUE. "
cTipoVia:="PARQUE"
cDir1:=SUBSTR(cDir1,07)
CASE SUBSTR(cDir1,02)="C "
cTipoVia:="CALLE+DE+"
cDir1:=SUBSTR(cDir1,03)
CASE SUBSTR(cDir1,05)="CALLE "
cTipoVia:="CALLE+DE+"
cDir1:=SUBSTR(cDir1,07)
CASE SUBSTR(cDir1,03)="C/ "
cTipoVia:="CALLE+DE+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,02)="C/"
cTipoVia:="CALLE+DE+"
cDir1:=SUBSTR(cDir1,03)
CASE SUBSTR(cDir1,02)="C-"
cTipoVia:="CALLE+DE+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="CT "
cTipoVia:="CARRETERA+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="CT."
cTipoVia:="CARRETERA+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="CTA."
cTipoVia:="CARRETERA+"
cDir1:=SUBSTR(cDir1,05)
CASE SUBSTR(cDir1,03)="PZ "
cTipoVia:="PLAZA+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="PZ."
cTipoVia:="PLAZA+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="PZA"
cTipoVia:="PLAZA+"
cDir1:=SUBSTR(cDir1,05)
CASE SUBSTR(cDir1,03)="PZA."
cTipoVia:="PLAZA+"
cDir1:=SUBSTR(cDir1,05)
CASE SUBSTR(cDir1,03)="PL "
cTipoVia:="PLAZA+"
cDir1:=SUBSTR(cDir1,04)
CASE SUBSTR(cDir1,03)="PL."
cTipoVia:="PLAZA+"
cDir1:=SUBSTR(cDir1,04)
OTHERWISE
cTipoVia:="CALLE+DE+"
ENDCASE
cDir1:=LTRIM(cDir1)
cDir1:=STRTRAN(cDir1,"DR.","DOCTOR ")
cDir1:=STRTRAN(cDir1,"DR ","DOCTOR ")
cDir1:=STRTRAN(cDir1,"GRAL ","GENERAL")
cDir1:=STRTRAN(cDir1,"GRAL.","GENERAL")
cDir1:=STRTRAN(cDir1,"FCO ","FRANCISCO")
cDir1:=STRTRAN(cDir1,"FCO.","FRANCISCO")
j:=LEN(cdir1)
FOR I=1 TO LEN(cdir1)
IF LEN(cNum)>0 .AND. SUBSTR(cDir1,I,1)=" "
EXIT
ENDIF
IF VAL(SUBSTR(cDir1,I,1))>0
IF EMPTY(cNum)
j:=i
ENDIF
cNum:=cNum+SUBSTR(cDir1,I,1)
ENDIF
next
IF EMPTY(cNum)
cNum:="1"
ENDIF
cDir1:=LTRIM( SUBSTR(cDir1,1,j-1) )
cDir1:=STRTRAN(cDir1,",","")
return nil
************************************************************************I think you can download the file using link below.
http://www.xharbour.com/xhc/index.asp?p ... show_sub=1
Here is the description:
Class to generate Internet Explorer link line for Google Maps.
You can add multiple addresses for directions or one address for map.
You can also add information to search near address like Hotels or Food.
Mr Gale FoRD
I downloaded your class and it is working very well for me. Thank you for providing such a class. Very easy and simple to use.
Default( @cStreet, PadR( "BROADWAY 500", 40 ) )Lines 100, Functions/Procedures 1
Generating C source output to 'TestWebMapHb.c'...
Done.
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
TestWebMapHb.c:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_HB_FUN_DEFAULT' referenced from D:\FWHEXTRA\FWH SAMPLES\GOOGLEMAPSLINK GENRERATOR\TESTWEBMAPHB.OBJ
* Linking errors *
> Terminated with exit code 0.
#include 'fivewin.ch'
function Main()
local oWnd, oIe, oMap
DEFINE WINDOW oWnd
oIe := TActivex():New( oWnd, 'Shell.Explorer.2' )
oWnd:oClient := oIe
oMap := WebMap():New()
oMap:AddStop( 'Bengaluru, India' )
oMap:AddStop( 'Hyderabad, India' )
oMap:GenLink()
oIe:navigate( oMap:cLink )
ACTIVATE WINDOW oWnd MAXIMIZED
return nilError: Unresolved external '_HB_FUN_DEFAULT' referenced from D:\FWHEXTRA\FWH SAMPLES\GOOGLEMAPSLINK GENRERATOR\TESTWEBMAPHB.OBJ
default cStreet:= ''
default cCity:=''
default cState:=''
default cZip:=''
default cCountry:=''
/*
default( @cStreet, '' )
default( @cCity, '' )
default( @cState, '' )
default( @cZip, '' )
default( @cCountry, '' )
*/I include \xharbour\lib\ct.lib always. ct.lib has this default(..) function.
Anyway glad it works for you now. I find this class very simple to use, without cluttering our application code.
Thank you for your comments.
I have uploaded a newer version. It just adds print option and a FiveWin sample prg and rc.
Thanks Mr Gale FORd
I have downloaded your new files and your FW samples works very nice.
May I suggest if you would like to facility to specify latitude and longitude instead of address to display that location? Or as one of the points in the route.
The link to be generated is like "http://maps.google.com/maps?q=37.771008,-122.41175"
You can use Lat, Long coordinates instead of address. If you enter it like 37.771008,-122.41175 instead of the address
Gale FORd wrote:You can use Lat, Long coordinates instead of address. If you enter it like 37.771008,-122.41175 instead of the address
Gale,
Thanks for your contribution. WebMap is very easy to use and a useful class.
It's possible to add "markers" to the map by using your class.
I mean to add a location, as usual by using AddStopSep() method, and add a few more locations with different color markers. If not possible, by using WeMap class, can you give me some tips how to do this?
Regards,
George