sistem Posted November 27, 2012 Report Share Posted November 27, 2012 Local cHtml:="", oOle If !IsInternet() Msgalert("não conectado a internet.", "Aviso!") Return nil Endif Ferase(uRegPath+"\tempgmapdist.html") // uRegPath:= "c:\test" oOle:= CreateObject("InternetExplorer.Application") oOle:Visible := .t. oOle:ToolBar := .f. oOle:StatusBar := .t. oOle:MenuBar := .f. cHtml := MemoRead(uRegPath+"\gmapdist.html") cHtml := StrTran( cHtml, "ORIGEM", Alltrim(Empr->End_Empr)+", "+Alltrim(Empr->Nmr_Empr)+", "+Alltrim(Empr->Cid_Empr)+" - "+Empr->Est_Empr) cHtml := StrTran( cHtml, "DESTINO", Alltrim(Clie->End_Clie)+", "+Alltrim(Clie->Nmr_Clie)+" "+Alltrim(Clie->Cid_Clie)+" - "+Clie->Est_Clie) MemoWrit(uRegPath+"\tempgmapdist.html", chtml) oOle:Navigate2(uRegPath+"\tempgmapdist.html") hWnd:=oOle:hWnd ShowWindow(hWnd, 3 ) //SW_MAXIMIZE=3 SW_NORMAL=1 SW_MINIMIZE=6 BringWindowToTop(hWnd) Return nilid=code>id=code>arquivo html => gmapdist.html var map, geocoder; var mapDisplay, directionsService; function initialize() { var myOptions = {zoom: 15,mapTypeId: google.maps.MapTypeId.ROADMAP}; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); geocoder = new google.maps.Geocoder(); var enderDe = "ORIGEM"; var enderAte = "DESTINO"; geocoder.geocode( { 'address': enderAte, 'region' : 'BR'},trataLocs); initializeDirections (); calcRota (enderDe, enderAte); } function initializeDirections () { directionsService = new google.maps.DirectionsService(); mapDisplay = new google.maps.DirectionsRenderer(); mapDisplay.setMap(map); mapDisplay.setPanel(document.getElementById("panel")) } function calcRota(endDe, endPara) { var request = { origin:endDe, destination:endPara, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { mapDisplay.setDirections(response) } }) } function trataLocs (results, status) { var elem = document.getElementById('msg'); if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); if (results.length > 1) { var i, txt = ''; elem.innerHTML = 'O endereço exato não foi localizado - há ' + results.length.toString() + ' resultados aproximados. '; for (i = 0; i < results.length; i++) { txt = txt + ' if (i == 0) txt = txt + ' selected="selected"'; txt = txt + '>' + results.formatted_address + ' ';} txt = txt + '' elem.innerHTML = elem.innerHTML + txt; } } else elem.innerHTML = 'Erro no tratamento do endereço : ' + status + ''; } id=code> id=code> Editado por - sistem on 27/11/2012 17:33:01 Quote Link to comment Share on other sites More sharing options...
sistem Posted November 27, 2012 Author Report Share Posted November 27, 2012 Local cHtml:="", oOle If !IsInternet() Msgalert("não conectado a internet.", "Aviso!") Return nil Endif Ferase(uRegPath+"\tempgmapdist.html") // uRegPath:= "c:\test" oOle:= CreateObject("InternetExplorer.Application") oOle:Visible := .t. oOle:ToolBar := .f. oOle:StatusBar := .t. oOle:MenuBar := .f. cHtml := MemoRead(uRegPath+"\gmapdist.html") cHtml := StrTran( cHtml, "ORIGEM", Alltrim(Empr->End_Empr)+", "+Alltrim(Empr->Nmr_Empr)+", "+Alltrim(Empr->Cid_Empr)+" - "+Empr->Est_Empr) cHtml := StrTran( cHtml, "DESTINO", Alltrim(Clie->End_Clie)+", "+Alltrim(Clie->Nmr_Clie)+" "+Alltrim(Clie->Cid_Clie)+" - "+Clie->Est_Clie) MemoWrit(uRegPath+"\tempgmapdist.html", chtml) oOle:Navigate2(uRegPath+"\tempgmapdist.html") hWnd:=oOle:hWnd ShowWindow(hWnd, 3 ) //SW_MAXIMIZE=3 SW_NORMAL=1 SW_MINIMIZE=6 BringWindowToTop(hWnd) Return nilid=code>id=code>arquivo html => gmapdist.html var map, geocoder; var mapDisplay, directionsService; function initialize() { var myOptions = {zoom: 15,mapTypeId: google.maps.MapTypeId.ROADMAP}; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); geocoder = new google.maps.Geocoder(); var enderDe = "ORIGEM"; var enderAte = "DESTINO"; geocoder.geocode( { 'address': enderAte, 'region' : 'BR'},trataLocs); initializeDirections (); calcRota (enderDe, enderAte); } function initializeDirections () { directionsService = new google.maps.DirectionsService(); mapDisplay = new google.maps.DirectionsRenderer(); mapDisplay.setMap(map); mapDisplay.setPanel(document.getElementById("panel")) } function calcRota(endDe, endPara) { var request = { origin:endDe, destination:endPara, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { mapDisplay.setDirections(response) } }) } function trataLocs (results, status) { var elem = document.getElementById('msg'); if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); if (results.length > 1) { var i, txt = ''; elem.innerHTML = 'O endereço exato não foi localizado - há ' + results.length.toString() + ' resultados aproximados. '; for (i = 0; i < results.length; i++) { txt = txt + ' if (i == 0) txt = txt + ' selected="selected"'; txt = txt + '>' + results.formatted_address + ' ';} txt = txt + '' elem.innerHTML = elem.innerHTML + txt; } } else elem.innerHTML = 'Erro no tratamento do endereço : ' + status + ''; } id=code> id=code> Editado por - sistem on 27/11/2012 17:33:01 Quote Link to comment Share on other sites More sharing options...
Daniel Lopes Filho Posted November 28, 2012 Report Share Posted November 28, 2012 parabéns por compartilhar o código xharbour 1.1.0 + gtwvw + fw 8.04+vsx e começando + xbrowse migrando p/ o 10.2 e nfe (classe do gilmer) e futuramente paf-ecf msn..: zazibr@hotmail.com skype: zazibr Daniel lopes Filho Campo Grande/MS Quote Link to comment Share on other sites More sharing options...
Theotokos Posted November 28, 2012 Report Share Posted November 28, 2012 Vlw! Parabens pelo código... Quote Link to comment Share on other sites More sharing options...
Daniel Lopes Filho Posted November 29, 2012 Report Share Posted November 29, 2012 voce tinha postado inicialmente uma imagem com várias rotas como que ficaria no exemplo acima ? "varios" DESTINO ? cHtml := StrTran( cHtml, "DESTINO", Alltrim(Clie->End_Clie)+", "+Alltrim(Clie->Nmr_Clie)+" "+Alltrim(Clie->Cid_Clie)+" - "+Clie->Est_Clie) xharbour 1.1.0 + gtwvw + fw 8.04+vsx e começando + xbrowse migrando p/ o 10.2 e nfe (classe do gilmer) e futuramente paf-ecf msn..: zazibr@hotmail.com skype: zazibr Daniel lopes Filho Campo Grande/MS Quote Link to comment Share on other sites More sharing options...
sistem Posted November 29, 2012 Author Report Share Posted November 29, 2012 amigo o exemplo acima é a distância geodesica entre 2 pontos(menor distancia em uma esfera(globo)) no seu caso teria que usar gPolyline do google maps, vamos ver como fica. Lembrei de topologia de rede o amigo quer ligar um ponto a outro ponto esse ultimo ponto ligar um terceiro ponto ou seria em forma de estrela? Quote Link to comment Share on other sites More sharing options...
Luiz Fernando Posted November 29, 2012 Report Share Posted November 29, 2012 Vlw Sistem por mais esta contribuição... Obrigado Luiz Fernando msn: empresoft@globo.com skype:empresoft empresoft@globo.com FWH 9.12,XHARBOUR 1.2,ADS 9.0 FWH1104,XHARBOUR 1.2 Rev.6717, MYSQL c\ SQLLIB FREE Quote Link to comment Share on other sites More sharing options...
sistem Posted November 29, 2012 Author Report Share Posted November 29, 2012 vlw gente depois irei postar exemplo com mutiplos pontos com gpolyline para o amigo zazibr obs: buscando o html de um host da internet com o exemplo acima Function GOOGLE_MAPA_DIST() Local cHtml:="", oOle If !IsInternet() Msgalert("não conectado a internet.", "Aviso!") Return nil Endif cHtml := WebConnect():New() cHtml := cHtml:Open( "http://www.sistem.net.br/gmapdist.html" ) Ferase(uRegPath+"\tempgmapdist.html") oOle:= CreateObject("InternetExplorer.Application") oOle:Visible := .t. oOle:ToolBar := .f. oOle:StatusBar := .t. oOle:MenuBar := .f. // cHtml := MemoRead(uRegPath+"\gmapdist.html") // linha desativada cHtml := StrTran( cHtml, "ORIGEM", Alltrim(Empr->End_Empr)+", "+Alltrim(Empr->Nmr_Empr)+", "+Alltrim(Empr->Cid_Empr)+" - "+Empr->Est_Empr) cHtml := StrTran( cHtml, "DESTINO", Alltrim(Clie->End_Clie)+", "+Alltrim(Clie->Nmr_Clie)+" "+Alltrim(Clie->Cid_Clie)+" - "+Clie->Est_Clie) MemoWrit(uRegPath+"\tempgmapdist.html", chtml) oOle:Navigate2(uRegPath+"\tempgmapdist.html") hWnd:=oOle:hWnd ShowWindow(hWnd, 3 ) //SW_MAXIMIZE=3 SW_NORMAL=1 SW_MINIMIZE=6 BringWindowToTop(hWnd) Return nil id=code>id=code>a classe WebConnect tem aqui no forum é soh pesquisar, nao lembro o autor +acho que seja o lailton Quote Link to comment Share on other sites More sharing options...
marcioe Posted December 6, 2012 Report Share Posted December 6, 2012 AMIGO, TENTEI, MAS NÃO DEU CERTO Dà ERRO EM WebConnect() informaisvrb@gmail.com MSN mastermarvrb@msn.com SKYPE informaisvrb .: 32-9104-0562 :. Quote Link to comment Share on other sites More sharing options...
sistem Posted December 6, 2012 Author Report Share Posted December 6, 2012 *======================= #include "fivewin.ch" Class WebConnect Data oWeb Method New() Constructor Method Open() Method End() INLINE ::oWeb:=Self:=Nil EndClass *-- Method New() Class WebConnect Try ::oWeb := CreateObject('MSXML2.XMLHTTP') Catch ::oWeb := CreateObject('Microsoft.XMLHTTP') End Return Self *-- Method Open( cUrl ) Class WebConnect Local cRet := "" If ValType( cUrl ) == 'U' Return cRet EndIf Try ::oWeb:Open("POST",cUrl,.f.) ::oWeb:Send() cRet := ::oWeb:responseBody Catch; End Return cRet id=code>id=code> Quote Link to comment Share on other sites More sharing options...
marcioe Posted December 6, 2012 Report Share Posted December 6, 2012 OBRIGADO AMIGO, ESTA FUNCIONANDO POREM cHtml:Open( "http://www.sistem.net.br/gmapdist.html" ) TEM COMO MUDAR PARA ALGO DE DOMINIO PULICO, pois se voce mudar o endereço do seu site ele para. aproveitando de sua boa vontade, ele poderia abrir com o navegador padrão do usaurio. pois esse I.E. é uma caca... Editado por - marcioe on 06/12/2012 09:28:21 Quote Link to comment Share on other sites More sharing options...
sistem Posted December 6, 2012 Author Report Share Posted December 6, 2012 macio TEM COMO MUDAR PARA ALGO DE DOMINIO PULICO? tem, mais vc pode usar no proprio computador subistituir as linhas: cHtml := WebConnect():New() cHtml := cHtml:Open( "http://www.sistem.net.br/gmapdist.html" ) por: cHtml := MemoRead(uRegPath+"\gmapdist.html") o codigo gmapdist.html ta logo acima eu tenho o google chrome portable e testei assim e funciona, linha de comando: WINEXEC( ....googlechromeportable e:\test\tempgmapdist.html se preferir usar o codigo de seu computador nao tenho outro navegado para teste Editado por - sistem on 06/12/2012 10:25:43 Quote Link to comment Share on other sites More sharing options...
marcioe Posted December 6, 2012 Report Share Posted December 6, 2012 Amigo, obrigado por responder. Cada dia que passa o negocio fica melhor. informaisvrb@gmail.com MSN mastermarvrb@msn.com SKYPE informaisvrb .: 32-9104-0562 :. Quote Link to comment Share on other sites More sharing options...
sistem Posted March 23, 2017 Author Report Share Posted March 23, 2017 passei o link no inicio do post, que faz isto: Function GOOGLE_MAPA_DIST() Local cHtml:="", oOle If !IsInternet() Msgalert("não conectado a internet.", "Aviso!") Return nil Endif // cHtml := WebConnect():New() // cHtml := cHtml:Open( "http://www.testeeeeeeee.com/gmapdist.html" ) // arquivo na internet cHtml := MemoRead("e:\gmapdist.html") // arquivo no computador local unidade E: como exemplo Ferase("e:\tempgmapdist.html") TRY oOle:= CreateObject("InternetExplorer.Application") CATCH TRY oOle:= CreateObject("InternetExplorer.Application") CATCH oError MsgAlert( "Erro! Internet Explorer não abriu. [" + Ole2TxtError()+ "]" + oError:description ) Return nil END END oOle:Visible := .t. oOle:ToolBar := .f. oOle:StatusBar := .t. oOle:MenuBar := .f. cHtml := StrTran( cHtml, "ORIGEM", Alltrim(Empr->End_Empr)+", "+Alltrim(Empr->Nmr_Empr)+", "+Alltrim(Empr->Cid_Empr)+" - "+Empr->Est_Empr) cHtml := StrTran( cHtml, "DESTINO", Alltrim(Clie->End_Clie)+", "+Alltrim(Clie->Nmr_Clie)+" "+Alltrim(Clie->Cid_Clie)+" - "+Clie->Est_Clie) MemoWrit("e:\tempgmapdist.html", chtml) oOle:Navigate2("e:\tempgmapdist.html") hWnd:=oOle:hWnd ShowWindow(hWnd, 3 ) //SW_MAXIMIZE=3 SW_NORMAL=1 SW_MINIMIZE=6 BringWindowToTop(hWnd) oOle := nil Return nil o conteudo arquivo gmapdist.html é : <html><head><title>Mapa Distancia</title> <script type='text/javascript' src='http://maps.google.com/maps/api/js?v=3.1&sensor=false&language=pt-BR'></script> <script type='text/javascript'> var map, geocoder; var mapDisplay, directionsService; function initialize() { var myOptions = {zoom: 15,mapTypeId: google.maps.MapTypeId.ROADMAP}; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); geocoder = new google.maps.Geocoder(); var enderDe = "ORIGEM"; var enderAte = "DESTINO"; geocoder.geocode( { 'address': enderAte, 'region' : 'BR'},trataLocs); initializeDirections (); calcRota (enderDe, enderAte); } function initializeDirections () { directionsService = new google.maps.DirectionsService(); mapDisplay = new google.maps.DirectionsRenderer(); mapDisplay.setMap(map); mapDisplay.setPanel(document.getElementById("panel")) } function calcRota(endDe, endPara) { var request = { origin:endDe, destination:endPara, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { mapDisplay.setDirections(response) } }) } function trataLocs (results, status) { var elem = document.getElementById('msg'); if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); if (results.length > 1) { var i, txt = '<select style="font-family:Verdana;font-size:8pt;width=550px;" onchange="mostraEnd(this.options[this.selectedIndex].text);">'; elem.innerHTML = 'O endereço exato não foi localizado - há ' + results.length.toString() + ' resultados aproximados.<br />'; for (i = 0; i < results.length; i++) { txt = txt + '<option value="' + i.toString() + '"'; if (i == 0) txt = txt + ' selected="selected"'; txt = txt + '>' + results[i].formatted_address + '</option>'; } txt = txt + '</select>' elem.innerHTML = elem.innerHTML + txt; } } else elem.innerHTML = 'Erro no tratamento do endereço :<br /><b>' + status + '</b>'; } </script> </head> <body onload='initialize();' style='font-family:Verdana;font-size:8pt;margin:5px 0 5px 0;'> <center> <div id='map_canvas' style='width:800px;height:450px'></div> <div id='panel' style='width:550px;height:450px'></div> </center> </html> o resultado é: como o topic ta com varios exemplos nao sei se é isto o pretendido Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.