#Include "FiveWin.ch"#Define CLR_MENTA nRGB
( 221,
255,
238 )#Define CLR_HMENTA nRGB
( 000,
128,
000 )// Ideia original:// http://www.pctoledo.com.br/forum/viewto ... =1&t=15482// Special thanks ao autor do topico: Billy1943. - 01/10/2014FUNCTION Google_Rua
() LOCAL oWnd, oActiveX, oFnt, oFont, nKey := VK_RETURN
LOCAL cEvents :=
"" LOCAL oMapa, mde_uf, mpara_uf, mde_cid, mpara_cid, mde_rua, mpara_rua
LOCAL oGet1, oGet2, oGet3, oGet4, oBusca, oSaida
LOCAL nEnde :=
"", nCid :=
"", nPais :=
"" TestWebMapFw
( nEnde, nCid, nPais
)RETURN NILFUNCTION 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
) // COR NO GET - ADD EM: 15/07/2013 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 REDEFINE GET cCity
ID 300 OF oDlg
UPDATE REDEFINE GET cCountry
ID 400 OF oDlg
UPDATE REDEFINE COMBOBOX cWhatsNear
ITEMS aWhatsNear
ID 140 OF oDlg
UPDATE REDEFINE GET cStreet2
ID 202 OF oDlg
UPDATE REDEFINE GET cCity2
ID 302 OF oDlg
UPDATE REDEFINE GET cStreet3
ID 203 OF oDlg
UPDATE REDEFINE GET cCity3
ID 303 OF oDlg
UPDATE REDEFINE GET cStreet4
ID 204 OF oDlg
UPDATE REDEFINE GET cCity4
ID 304 OF oDlg
UPDATE REDEFINE GET cStreet5
ID 205 OF oDlg
UPDATE REDEFINE GET cCity5
ID 305 OF oDlg
UPDATE REDEFINE GET nZoomLevel
ID 141 OF oDlg
UPDATE 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 NILfunction 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
() endifreturn nilfunction 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&#
058;SetProp
( "Visible", .T.
) oActiveX&#
058;SetProp
( "Toolbar", .T.
) oActiveX&#
058;SetProp
( "Statusbar", .T.
) oActiveX&#
058;SetProp
( "MenuBar", .F.
) oActiveX&#
058;Do
( "Navigate", oWebMap:
cLink ) sysrefresh
() // MsgInfo( oActiveX:GetProp( "StatusBar" ) ) ACTIVATE WINDOW oWnd
sysrefresh
() endifreturn nilfunction EventInfo
( event, aParams, pParams, oActiveX
) local cMsg :=
"Event: " + cValToChar
( event
) + CRLF
local n
cMsg +=
"Params: " + CRLF
for n =
1 to Len
( aParams
) cMsg += cValToChar
( aParams
[ n
] ) + CRLF
next if event ==
"BeforeNavigate2" //MsgInfo( aParams[ 2 ] ) //SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation endifreturn cMsg + CRLF
// #include "FiveWin.ch"#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
CLASSMETHOD 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() endifRETURN( 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
),
' ',
'+' ) ) endifRETURN 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
) ) endcaseRETURN nil//////////////////////////////////////////////// Method GenLink//////////////////////////////////////////// Purpose - To generate link string that// can be passed to Internet Explorer// Shell or link string can be emailedMETHOD 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' endifRETURN( ::
cLink )// WEBMAP.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"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
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
}
*/