Page 1 of 2

Google maps rotes

Posted: Fri Aug 07, 2009 2:26 pm
by norberto
HI, someone has an sample to trace rotes in google maps? very thanks

Re: Google maps rotes

Posted: Fri Aug 07, 2009 3:39 pm
by PeterHarmes
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

Re: Google maps rotes

Posted: Fri Aug 07, 2009 4:43 pm
by norberto
Pete, you have an link for community? thanks

Link FW-Google maps with routes

Posted: Fri Aug 07, 2009 7:29 pm
by PAUL SIMM
Here is the code I use to locate Pickup address delivery address or map route.
DIR1,DIR2,DIR3 ARE STREET ADDRESSES
CIUDAD1,CIUDAD2,CIUDAD3 ARE CITIES
DP1,DP2,DP3 ARE POSTAL CODES.

Code: Select all

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
************************************************************************
 

Re: Google maps rotes

Posted: Mon Aug 10, 2009 3:22 am
by Gale FORd
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.

Re: Google maps rotes

Posted: Mon Aug 10, 2009 4:35 am
by nageswaragunupudi
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.

Re: Google maps rotes

Posted: Mon Aug 10, 2009 4:53 am
by anserkk
Dear Mr.Rao,

When I compile the Sample, I get a message saying that the Function Default() is missing. Do I have to link any other libraries. I have used FWH provided Buildx.bat to generate the exe

Code: Select all

   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.
Regards
Anser

Re: Google maps rotes

Posted: Mon Aug 10, 2009 7:15 am
by nageswaragunupudi
Mr Anser

Don't compile the sample as such. That seems to be written for xhrabour without fwh
Write it in your own way for using with FWH.
Please try this small sample

Code: Select all

#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 nil
 
Link with the downloaded webmap.prg
I feel we can add webmap.prg to our personal library

Re: Google maps rotes

Posted: Mon Aug 10, 2009 9:40 am
by anserkk
Dear Mr.Rao,

I tried your sample, but still I get the same error. I find that WebMap.Prg is trying to make use of the function Default() in line no. 68 to 72 in the Method AddStopSep().
Error: Unresolved external '_HB_FUN_DEFAULT' referenced from D:\FWHEXTRA\FWH SAMPLES\GOOGLEMAPSLINK GENRERATOR\TESTWEBMAPHB.OBJ
So I changed lines 68 to 72 of WebMap.Prg as below and it is working fine

Code: Select all

   default cStreet:= '' 
   default cCity:=''
   default cState:=''
   default cZip:=''
   default cCountry:=''   
   
   /*
   default( @cStreet, '' )
   default( @cCity, '' )
   default( @cState, '' )
   default( @cZip, '' )
   default( @cCountry, '' )
   */
Regards
Anser

Re: Google maps rotes

Posted: Mon Aug 10, 2009 10:25 am
by nageswaragunupudi
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.

Re: Google maps rotes

Posted: Mon Aug 10, 2009 3:29 pm
by Gale FORd
Thank you for your comments.

I have uploaded a newer version. It just adds print option and a FiveWin sample prg and rc.

http://www.xharbour.com/xhc/index.asp?p ... show_sub=1

Re: Google maps rotes

Posted: Mon Aug 10, 2009 4:05 pm
by nageswaragunupudi
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"

Re: Google maps rotes

Posted: Mon Aug 10, 2009 4:37 pm
by Gale FORd
You can use Lat, Long coordinates instead of address. If you enter it like 37.771008,-122.41175 instead of the address

Re: Google maps rotes

Posted: Mon Aug 10, 2009 4:48 pm
by nageswaragunupudi
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
Thanks

Actually, for an application I am planning, I need the other way round. If the user clicks on the map, my application should be able read the Lat Long of that place. I understand Google API provides it. I don't know more about it. Any help from anybody to read the Lat Long from FWH app is welcome

Re: Google maps rotes

Posted: Mon Aug 10, 2009 4:55 pm
by George
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