// CALLES.PRG y CALLES.RC
#include "FiveWin.ch"
#Define CLR_MENTA nRGB( 221, 255, 238 )
STATIC lSaida := .F., lLigaBotao := .F., oDlg
FUNCTION Google_Calles() // CALLE = RUA(Portugues)
LOCAL nEnde := "", nCid := "", nPais := ""
TestWebMapFw( nEnde, nCid, nPais )
RETURN NIL
FUNCTION Testwebmapfw( nEnde, nCid, nPais )
LOCAL oDlg, oActiveX, oFnt, oFont
LOCAL aWhatsNear
LOCAL cStreet, cCity, cCountry
LOCAL cStreet2, cCity2
LOCAL cStreet3, cCity3
LOCAL cStreet4, cCity4
LOCAL cStreet5, cCity5
LOCAL cWhatsNear
LOCAL nZoomLevel
DEFAULT cStreet := "AV PAULISTA, 1313 ", ;
cCity := "SAO PAULO ", ;
cCountry := "BRASIL " , ;
cStreet2 := SPACE( 80 ), ;
cCity2 := SPACE( 80 ), ;
cStreet3 := SPACE( 80 ), ;
cCity3 := SPACE( 80 ), ;
cStreet4 := SPACE( 80 ), ;
cCity4 := SPACE( 80 ), ;
cStreet5 := SPACE( 80 ), ;
cCity5 := SPACE( 80 )
cWhatsNear := ''
nZoomLevel := 0
aWhatsNear := { ;
'', ;
'Hotel', ;
'Posto de Gasolina', ;
'Praça de Alimentação', ;
'Parque', ;
'Peças e Acessórios de Carros', ;
'Peças de Caminhões', ;
'Ferrovias' ;
}
SetBalloon( .T. ) // Balloon shape required for tooltips
SkinButtons() // Botoes Coloridos nas novas versoes
SetGetColorFocus( CLR_MENTA )
tGet():lDisColors := .F.
tGet():nClrTextDis := CLR_BLUE
tGet():nClrPaneDis := CLR_HRED // SOFTYELLOW
DEFINE FONT oFnt NAME "Ms Sans Serif" SIZE 00, -12 BOLD
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD
DEFINE DIALOG oDlg RESOURCE "MAP" COLORS CLR_BLACK, CLR_WHITE TRANSPARENT
oDlg:lHelpIcon := .F.
REDEFINE GET cStreet ID 200 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cCity ID 300 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cCountry ID 400 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE COMBOBOX cWhatsNear ITEMS aWhatsNear ID 140 OF oDlg UPDATE
REDEFINE GET cStreet2 ID 202 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cCity2 ID 302 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cStreet3 ID 203 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cCity3 ID 303 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cStreet4 ID 204 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cCity4 ID 304 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cStreet5 ID 205 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET cCity5 ID 305 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE GET nZoomLevel ID 141 OF oDlg UPDATE COLORS CLR_HBLUE, CLR_WHITE ;
FONT oFont
REDEFINE BUTTON ID 1 OF oDlg ;
ACTION ShowInWin(cStreet,cCity,cCountry,cStreet2,cCity2,cStreet3,cCity3,cStreet4,cCity4,cStreet5,cCity5,cWhatsNear,nZoomLevel)
REDEFINE BUTTON ID 150 OF oDlg ;
ACTION ShowFull(cStreet,cCity,cCountry,cStreet2,cCity2,cStreet3,cCity3,cStreet4,cCity4,cStreet5,cCity5,cWhatsNear,nZoomLevel)
SET FONT OF oDlg TO oFnt
ACTIVATE DIALOG oDlg CENTERED
oFnt:End()
oFont:End()
RETURN NIL
function ShowFull(cStreet,cCity,cCountry,cStreet2,cCity2,cStreet3,cCity3,cStreet4,cCity4,cStreet5,cCity5,cWhatsNear,nZoomLevel)
local oWnd, oActiveX, oBar
local cEvents := ""
local oWebMap
oWebMap := WebMap():new()
oWebMap:AddStopSep( cStreet, cCity,,, cCountry )
// you can format address yourself or just
// type address string like in google maps
// using :AddStop() instead of :AddStopSep()
//
// oWebMap:AddStop( alltrim( cStreet )+','+;
// alltrim( cCity )+' '+alltrim( cCountry ) )
// or
// oWebMap:AddStop( 'My Address Info' )
oWebMap:AddStopSep( cStreet2, cCity2 )
oWebMap:AddStopSep( cStreet3, cCity3 )
oWebMap:AddStopSep( cStreet4, cCity4 )
oWebMap:AddStopSep( cStreet5, cCity5 )
oWebMap:cWhatsNear := cWhatsNear
oWebMap:nZoomLevel := nZoomLevel
oWebMap:GenLink()
if .not. empty( oWebMap:cLink )
ShellExecute( 0, "open", oWebMap:cLink,,, 5 )
// You can also use this for more control
/*
oActiveX := TOleAuto():New("InternetExplorer.Application")
oActiveX:Visible := .T.
oActiveX:Toolbar := .T.
oActiveX:Statusbar :=.T.
oActiveX:MenuBar := .T.
oActiveX:Navigate( oWebMap:cLink )
*/
sysrefresh()
endif
return nil
function ShowInWin(cStreet,cCity,cCountry,cStreet2,cCity2,cStreet3,cCity3,cStreet4,cCity4,cStreet5,cCity5,cWhatsNear,nZoomLevel)
local oWnd, oActiveX, oBar
local cEvents := ""
local oWebMap
oWebMap := WebMap():new()
oWebMap:AddStopSep( cStreet, cCity,,, cCountry )
oWebMap:AddStopSep( cStreet2, cCity2 )
oWebMap:AddStopSep( cStreet3, cCity3 )
oWebMap:AddStopSep( cStreet4, cCity4 )
oWebMap:AddStopSep( cStreet5, cCity5 )
oWebMap:cWhatsNear := cWhatsNear
oWebMap:nZoomLevel := nZoomLevel
oWebMap:GenLink()
if .not. empty( oWebMap:cLink )
DEFINE WINDOW oWnd TITLE "Google Map Localização" ;
FROM 0, 0 TO 600, 800 pixel
oActiveX = TActiveX():New( oWnd, "Shell.Explorer" )
// oActiveX = TOleAuto():New("InternetExplorer.Application")
// oActivex:Silent := .T. // Para Evitar: Erro de Script na Pagina.
oWnd:oClient = oActiveX // To fill the entire window surface
// these setprop options do not work?
oActiveX:SetProp( "Visible", .T. )
oActiveX:SetProp( "Toolbar", .T. )
oActiveX:SetProp( "Statusbar", .T. )
oActiveX:SetProp( "MenuBar", .F. )
oActiveX:Do( "Navigate", oWebMap:cLink )
sysrefresh()
// MsgInfo( oActiveX:GetProp( "StatusBar" ) )
ACTIVATE WINDOW oWnd
sysrefresh()
endif
return nil
FUNCTION VALIDA_GET1( cmpara_uf )
IF GETASYNCKEY( VK_UP ) // Para nao perder o foco do dialgo
RETURN( .F. )
ENDIF
IF EMPTY( cmpara_uf )
MsgInfo( OemToAnsi( "OPERA€ÇO INVµLIDA! " )+CRLF+ ;
OemToAnsi( "DIGITIE O NOME DA UF... " )+CRLF+ ;
OemToAnsi( "TECLE <ENTER> PARA CONTINUAR..." ), ;
OemToAnsi( "OPERA€ÇO INVµLIDA! " ) )
lLigaBotao := .F.
RETURN( .F. )
ENDIF
RETURN( .T. )
FUNCTION VALIDA_GET2( cmpara_cid )
IF EMPTY( cmpara_cid )
MsgInfo( OemToAnsi( "OPERA€ÇO INVµLIDA! " )+CRLF+ ;
OemToAnsi( "DIGITIE O NOME DA CIDADE... " )+CRLF+ ;
OemToAnsi( "TECLE <ENTER> PARA CONTINUAR..." ), ;
OemToAnsi( "OPERA€ÇO INVµLIDA! " ) )
lLigaBotao := .F.
RETURN( .F. )
ENDIF
RETURN( .T. )
FUNCTION VALIDA_BOTAO( cmpara_rua, oBusca )
IF EMPTY( cmpara_rua )
MsgInfo( OemToAnsi( "OPERA€ÇO INVµLIDA! " )+CRLF+ ;
OemToAnsi( "DIGITIE O NOME DA RUA... " )+CRLF+ ;
OemToAnsi( "TECLE <ENTER> PARA CONTINUAR..." ), ;
OemToAnsi( "OPERA€ÇO INVµLIDA! " ) )
lLigaBotao := .F.
RETURN( .F. )
ENDIF
// TUDO NORMAL, VAI BUSCAR NO GOOGLE
lLigaBotao := .T.
oBusca:Enable()
oBusca:Refresh()
RETURN( .T. )
#include "Hbclass.ch"
CREATE CLASS WebMap
VAR aAddress
VAR nZoomLevel
VAR cMapType // 'MAP' = regular map, 'ROUTE' = route
VAR oIe
VAR cLink
VAR cWhatsNear
METHOD New
METHOD AddStop
METHOD AddStopSep
METHOD GenLink
END CLASS
METHOD New( xAddress, nZoomLevel )
if nZoomLevel == nil
// default to 0 for auto calc size
::nZoomLevel := 0
else
::nZoomLevel := nZoomLevel
endif
::cLink := ''
::cWhatsNear := ''
// Initialize address array
do case
case xAddress == nil
::aAddress := {}
case valtype( xAddress ) == 'A'
::aAddress := xAddress
otherwise
::aAddress := { xAddress }
endcase
// if address passed on command line lets auto create link string
if len( ::aAddress ) > 0
::GenLink()
endif
RETURN( self )
//////////////////////////////////////////
////// Method AddStop
//////////////////////////////////////////
// Purpose - To add a pre-formatted address
// to ::aAddress
//
METHOD AddStop( cAddress )
if cAddress != nil
// convert spaces to +
aadd( ::aAddress, strtran( trim( cAddress ),' ', '+' ) )
endif
RETURN nil
//////////////////////////////////////////
////// Method AddStopSep
//////////////////////////////////////////
// Purpose - To add an address to ::aAddress
// when you have seperate street,
// city, zip etc that need to be
// formated into Google Map format
// Note - You can format address yourself or just
// type address string like in google maps
// using :AddStop() instead of :AddStopSep()
//
METHOD AddStopSep( cStreet, cCity, cState, cZip, cCountry )
local cAddr2
* default( @cStreet, '' )
* default( @cCity, '' )
* default( @cState, '' )
* default( @cZip, '' )
* default( @cCountry, '' )
DEFAULT cStreet:= ""
DEFAULT cCity:= ""
DEFAULT cState:= ""
DEFAULT cZip:= ""
DEFAULT cCountry:= ""
cAddr2 := ltrim( trim( cCity )+' ' )
cAddr2 += ltrim( trim( cState )+' ' )
cAddr2 += ltrim( trim( cZip )+' ' )
cAddr2 += ltrim( trim( cCountry ) )
if at( ',', cAddr2 ) > 0
// Remove commas from this portion of address
cAddr2 := strtran( cAddr2,',', ' ' )
// Remove extra spaces if any
cAddr2 := strtran( cAddr2,' ', ' ' )
endif
do case
case .not. empty( cStreet ) .and. .not. empty( cAddr2 )
::AddStop( trim( cStreet)+', '+cAddr2 )
case empty( cStreet ) .and. .not. empty( cAddr2 )
::AddStop( cAddr2 )
case .not. empty( cStreet ) .and. empty( cAddr2 )
::AddStop( trim( cStreet) )
endcase
RETURN nil
//////////////////////////////////////////
////// Method GenLink
//////////////////////////////////////////
// Purpose - To generate link string that
// can be passed to Internet Explorer
// Shell or link string can be emailed
METHOD GenLink()
local nCounter, nFor
::cLink := 'http://maps.google.com/maps?'
do case
case len( ::aAddress ) = 0
// this will just display country map
::cMapType := 'MAP'
case len( ::aAddress ) > 1
// must be route so update map type
::cMapType := 'ROUTE'
otherwise
::cMapType := 'MAP'
endcase
for nFor := 1 to len( ::aAddress )
do case
case nFor = 1
if ::cMapType = 'ROUTE'
::cLink += 'saddr='+::aAddress[ nFor ]
else
// In order to use info near address
// Must be in map mode and not route mode
if empty( ::cWhatsNear )
::cLink += 'q='+::aAddress[ nFor ]
else
::cLink += 'q='+trim(::cWhatsNear)
::cLink += chr(38)+'near='+::aAddress[ nFor ]
endif
endif
case nFor = 2
::cLink += chr(38)+'daddr='+::aAddress[ nFor ]
otherwise
::cLink += ',+to:'+::aAddress[ nFor ]
endcase
next
if .not. empty( ::cLink )
// Extra options.
// I have commented out some of the ones that are not required
// ::cLink += chr(38)+'hl=en'
// ::cLink += chr(38)+'mra=pi'
// ::cLink += chr(38)+'mrcr=1'
// ::cLink += chr(38)+'sll=31.244355,-95.99896'
// ::cLink += chr(38)+'sspn=2.934965,5.108643'
// ::cLink += chr(38)+'ie=UTF8'
if ::nZoomLevel > 0
::cLink += chr(38)+'z='+ltrim( str( ::nZoomLevel ) )
endif
// ::cLink += chr(38)+'om=1'
endif
RETURN( ::cLink )
// CALLES.RC
/*
MAP DIALOG 170, 66, 315, 215
STYLE DS_ABSALIGN | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Google Maps Localização"
FONT 8, "MS Sans Serif"
{
EDITTEXT 200, 8, 17, 302, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 300, 8, 42, 150, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 400, 160, 42, 150, 12, WS_BORDER | WS_TABSTOP
CONTROL "Near", 140, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 8, 71, 167, 67
EDITTEXT 141, 189, 71, 22, 12, WS_BORDER | WS_TABSTOP
DEFPUSHBUTTON "&Mostrar no Navegador", 150, 19, 190, 110, 14
PUSHBUTTON "Mostrar &Dentro do Sistema", 1, 132, 190, 110, 14
PUSHBUTTON "&Saida", 2, 245, 190, 50, 14
EDITTEXT 202, 10, 122, 190, 12, ES_WANTRETURN | WS_BORDER | WS_TABSTOP
EDITTEXT 302, 209, 122, 100, 12, ES_WANTRETURN | WS_BORDER | WS_TABSTOP
EDITTEXT 203, 10, 138, 190, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 303, 209, 138, 100, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 204, 10, 155, 190, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 304, 209, 155, 100, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 205, 10, 171, 189, 12, WS_BORDER | WS_TABSTOP
EDITTEXT 305, 209, 171, 100, 12, WS_BORDER | WS_TABSTOP
LTEXT "Endereço e Número", -1, 8, 6, 190, 8
LTEXT "Cidade ou CEP", -1, 8, 32, 92, 8
LTEXT "País", -1, 159, 32, 92, 8
LTEXT "Extras que estão perto do endereço acima", -1, 8, 60, 170, 8
LTEXT "Para mais direções digite mais endereços", -1, 8, 96, 190, 8
LTEXT "Endereço e Número", -1, 10, 111, 189, 9
LTEXT "Cidade ou CEP", -1, 209, 112, 92, 8
LTEXT "Nível de Zoom ", -1, 189, 60, 100, 8
LTEXT "0 ou em branco = Melhor Ajuste", -1, 214, 73, 100, 8
}
*/