Jump to content
Fivewin Brasil

Google Maps


kapiaba

Recommended Posts

Google Maps - Não entendo porquê demora tanto...

#include "FiveWin.ch"
	STATIC cPais := "", cCiudad := "", cCalle := ""
STATIC oGet1, oGet2, oGet3, oBtn1, oBtn2, nSeg := 0, oWnd
	#ifndef XPP
   #define  HKEY_CLASSES_ROOT       2147483648
   #define  HKEY_CURRENT_USER       2147483649
   #define  HKEY_LOCAL_MACHINE      2147483650
   #define  HKEY_USERS              2147483651
   #define  HKEY_PERFORMANCE_DATA   2147483652
   #define  HKEY_CURRENT_CONFIG     2147483653
   #define  HKEY_DYN_DATA           2147483654
#else
   #define  HKEY_CLASSES_ROOT       1
   #define  HKEY_CURRENT_USER       2
   #define  HKEY_LOCAL_MACHINE      3
   #define  HKEY_USERS              4
   #define  HKEY_PERFORMANCE_DATA   5
   #define  HKEY_CURRENT_CONFIG     6
   #define  HKEY_DYN_DATA           7
#endif
	/*
#ifdef __XHARBOUR__
   #xtranslate HB_CurDrive()  => CurDrive()
#endif
*/
	FUNCTION Mapas()
	   LOCAL oForm
	   /*
   cPais   := LEFT( "ARGENTINA" + SPACE( 255 ), 255 ) // pais
   cCiudad := LEFT( "MERCEDES" + SPACE( 255 ), 255 ) // cidade
   cCalle  := LEFT( "29 575" + SPACE( 255 ), 255 )   // street/rua
   */
   cPais   := "BRASIL" + SPACE( 255 )
   cCiudad := "SAO PAULO" + SPACE( 255 )
   cCalle  := "NOVE DE JULHO" + SPACE( 255 )
	   DEFINE DIALOG oForm TITLE "Localizacion Google maps" FROM 05, 15 TO 40, 95
	   oForm:lHelpIcon := .F.
	   @ 07, 05 SAY "Rua:"     OF oForm PIXEL SIZE 50, 20 RIGHT
   @ 22, 05 SAY "Cidade:"  OF oForm PIXEL SIZE 50, 20 RIGHT
   @ 37, 05 SAY "Pais:"    OF oForm PIXEL SIZE 50, 20 RIGHT
	   @ 05, 65 GET oGet1 VAR cCalle  PICTURE "@S30"  OF oForm PIXEL
   @ 20, 65 GET oGet2 VAR cCiudad PICTURE "@S30"  OF oForm PIXEL
   @ 35, 65 GET oGet3 VAR cPais   PICTURE "@S30"  OF oForm PIXEL
	   @ 45, 00 ACTIVEX oWnd OF oForm PROGID "Shell.Explorer.2"
	   @ 22, 205 BUTTON oBtn1 OF oForm ;
      ACTION MsgRun( "Aguarde um Momento", "Aguarde um Momento", ;
                     { || VerMapa( oWnd ) } ) PIXEL
	   ACTIVATE DIALOG oForm CENTERED // ON INIT VerMapa( oWnd )
	RETURN nil
	STATIC FUNCTION VerMapa( oActivex )
	   LOCAL cHtml, oWnd
	   INTER_APP_WEB_CONFIG("MAPAS.EXE",11001) // Internet Explorer
	   cHtml := [ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ] + CRLF
   cHtml += [ <html xmlns="http://www.w3.org/1999/xhtml"> ] + CRLF
   cHtml += [ <head> ] + CRLF
   cHtml += [<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> ] + CRLF
   cHtml += [<title> </title> ] + CRLF
   cHtml += [<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAtOjLpIVcO8im8KJFR8pcMhQjskl1-YgiA_BGX2yRrf7htVrbmBTWZt39_v1rJ4xxwZZCEomegYBo1w" type="text/javascript"></script>] + CRLF
   cHtml += [<script type="text/javascript">] + CRLF
   cHtml += [var map = null;] + CRLF
   cHtml += [var geocoder = null;] + CRLF
   cHtml += [var coords = null;] + CRLF
   cHtml += [function initialize() {] + CRLF
   cHtml += [if (GBrowserIsCompatible()) {] + CRLF
   cHtml += [map = new GMap2(document.getElementById("map_canvas"));] + CRLF
   cHtml += [map.addControl(new GLargeMapControl());] + CRLF
   cHtml += [map.addControl(new GMapTypeControl());] + CRLF
   cHtml += [map.addControl(new GOverviewMapControl());] + CRLF
   cHtml += [geocoder = new GClientGeocoder();] + CRLF
   cHtml += [}] + CRLF
   cHtml += [}] + CRLF
   cHtml += [function showAddress(address, cAddressName) {] + CRLF
   cHtml += [if (geocoder) {] + CRLF
   cHtml += [geocoder.getLatLng(] + CRLF
   cHtml += [address,] + CRLF
   cHtml += [function(point) {] + CRLF
   cHtml += [if (!point) {] + CRLF
   cHtml += "showAddress2('" + ALLTRIM( cCiudad ) + "');" + CRLF
   cHtml += [} else {                                                      ] + CRLF
   cHtml += [map.setCenter(point, 15);                                  ] + CRLF
   cHtml += [var marker = new GMarker(point);                            ] + CRLF
   cHtml += [map.addOverlay(marker);                                    ] + CRLF
   cHtml += [coords = marker.getPoint();                                ] + CRLF
   cHtml += [var curl = cAddressName + "<p>" + coords.toUrlValue(6) + "</p>" ] + CRLF
   cHtml += [var button = '<input type="button" value="Imprimir" onClick="window.print()"/>;' ] + CRLF
   cHtml += [curl = curl + button ] + CRLF
   cHtml += [}                          ] + CRLF
   cHtml += [}                                ] + CRLF
   cHtml += [);                                     ] + CRLF
   cHtml += [}                                                                  ] + CRLF
   cHtml += [}                                                                    ] + CRLF
   cHtml += [function showAddress2(address) {        ] + CRLF
   cHtml += [if (geocoder) {                               ] + CRLF
   cHtml += [geocoder.getLatLng(                                 ] + CRLF
   cHtml += [address,                                                  ] + CRLF
   cHtml += [function(point) {                                              ] + CRLF
   cHtml += [if (!point) {                                                ] + CRLF
   cHtml += [alert(address + " no encontrado");                          ] + CRLF
   cHtml += [} else {                                                      ] + CRLF
   cHtml += [map.setCenter(point, 15);                                  ] + CRLF
   cHtml += [var marker = new GMarker(point);                            ] + CRLF
   cHtml += [map.addOverlay(marker);                                    ] + CRLF
   cHtml += [marker.openInfoWindowHtml(address);                        ] + CRLF
   cHtml += [}                                                            ] + CRLF
   cHtml += [}                                                              ] + CRLF
   cHtml += [);                                                               ] + CRLF
   cHtml += [}                                                                  ] + CRLF
   cHtml += [}                                                                    ] + CRLF
   cHtml += [</script>                                                            ] + CRLF
   cHtml += [</head>                                                                ] + CRLF
   cHtml += [<body onload="initialize();]
   cHtml += " showAddress('" + ALLTRIM( cCalle ) + ", " + ALLTRIM( cCiudad ) + "  " + ALLTRIM( cPais ) + "', '" + ALLTRIM( cCalle ) + ", " + ALLTRIM( cCiudad ) + "  " + ALLTRIM( cPais ) + "');"
   cHtml += [" onunload="GUnload()"] + CRLF
   cHtml += [<div id="map_canvas" style="width: 597px; height: 376px"></div> ] + CRLF
   cHtml += [</body>                                                               ] + CRLF
   cHtml += [</html>] + CRLF
	   MemoWrit( "mihtml.htm", chtml )
	   oActiveX:Silent := .T.     // Añadir
	   #ifdef __XHARBOUR__
	      SysRefresh()
	      oActiveX:DO( "Navigate2", ( CurDrive() + ":\" + CurDir() + "\MiHtml.htm" ) )
	   #else
	      oActiveX:DO( "Navigate2", ( HB_CurDrive() + ":\" + CurDir() + "\MiHtml.htm" ) )
	   #endif
	RETURN NIL
/*
Parametrize seu programa com a versão do seu navegador atual.
	Ex: se seu navegador for iexplorer 11 coloque assim
	INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)
*/
	FUNCTION INTER_APP_WEB_CONFIG( f_cNameProg, f_nVersion_IE )
	   Local oRegKey, cRegProgGet, lDeleteKey := .f.
  
   Default f_nVersion_IE := 11001
	   if IsWow64()
    
      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 1
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
      oRegKey:Set(f_cNameProg,1,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
      oRegKey:Set(f_cNameProg,0,4) // Padrao 1
      oRegKey:Close()
	   Else
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      cRegProgGet := oRegKey:GetBinary(f_cNameProg)
      //? cRegProgGet
      If Empty(cRegProgGet)
        oRegKey:Set(f_cNameProg,1,4)
      EndIf
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
        oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	   EndIf
	RETURN NIL


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...