Exemplo de mapa para versão nova do Google Maps

Exemplo de mapa para versão nova do Google Maps

Postby MGA » Mon Feb 03, 2014 1:20 pm

Tive que alterar o HTML para suportar a nova versão do GOOGLE MAPS, talvez possa ser útil para alguém.

Code: Select all  Expand view  RUN
#include "FiveWin.ch"

procedure Main()

   local oDialog, oActiveX
   local cEndereco := PadR( "AV. XV DE NOVEMBRO, 701", 80 )
   local cCidade   := PadR( "MARINGA, PR"            , 80 )
   local cPais     := PadR( "BRASIL"                 , 80 )

   DEFINE DIALOG oDialog RESOURCE "map"

   REDEFINE ACTIVEX oActiveX ID 100 OF oDialog PROGID "Shell.Explorer"

   REDEFINE GET cEndereco    ID 200 OF oDialog

   REDEFINE GET cCidade      ID 300 OF oDialog

   REDEFINE GET cPais        ID 400 OF oDialog
   
   REDEFINE BUTTON ID 1 OF oDialog ACTION Show( cEndereco, cCidade, cPais, oActiveX )

   ACTIVATE DIALOG oDialog CENTERED ON INIT Show( cEndereco, cCidade, cPais, oActiveX )

return
/******************************************************************************/
procedure Show( cEndereco, cCidade, cPais, oActiveX )

   local cHtml := MemoRead( "gmapv3.html" )

   cHtml = StrTran( cHtml, "<<STREET>>" , AllTrim( cEndereco ) )
   cHtml = StrTran( cHtml, "<<CITY>>"   , AllTrim( cCidade   ) )
   cHtml = StrTran( cHtml, "<<COUNTRY>>", AllTrim( cPais     ) )

   MemoWrit( "temp.html", cHtml )
   
   oActiveX :  Do( "Navigate2", hb_CurDrive() + ":\" + CurDir() + "\temp.html" )
   
return


GMAPV3.HTML:
Code: Select all  Expand view  RUN
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Geocoding service</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
      #panel {
        position: absolute;
        top: 5px;
        left: 50%;
        margin-left: -180px;
        z-index: 5;
        background-color: #fff;
        padding: 5px;
        border: 1px solid #999;
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
var geocoder;
var map;
function initialize() {
  geocoder = new google.maps.Geocoder();
  var latlng = new google.maps.LatLng(-23.347102,-51.979115);
  var mapOptions = {
    zoom: 15,
    center: latlng
  }
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}

function codeAddress() {
  var address = document.getElementById('address').value;
  geocoder.geocode( { 'address': address}, function(results, status) {
    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
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
    }
  });
}
function clickButton(){
    document.getElementById('button').click();
}

    </script>
  </head>
  <input id="address" type="hidden" value="<<STREET>>, <<CITY>>, <<COUNTRY>>">
  <input type="hidden" id="button"  value="Geocode" onclick="codeAddress()">
  <body onload="initialize(); codeAddress('<<STREET>>, <<CITY>>, <<COUNTRY>>')">
    <div id="map-canvas"></div>
  </body>
</html>


gmapv3.rc
Code: Select all  Expand view  RUN
1 24 "winxp/WindowsXP.Manifest"
#include <windows.h>

map DIALOG 9, 28, 418, 252
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Map location"
FONT 8, "MS Sans Serif"
{
 CONTROL "", 100, "TActiveX", 0 | WS_CHILD | WS_VISIBLE, 4, 5, 409, 191
 LTEXT "Street and number:", -1, 7, 201, 65, 8
 EDITTEXT 200, 5, 212, 189, 12
 LTEXT "City:", -1, 8, 227, 17, 8
 EDITTEXT 300, 5, 236, 92, 12
 LTEXT "Country:", -1, 104, 227, 28, 8
 EDITTEXT 400, 103, 236, 91, 12
 DEFPUSHBUTTON "&Search", IDOK, 207, 223, 50, 14
 PUSHBUTTON "&Exit", 2, 263, 223, 50, 14
}
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1254
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Exemplo de mapa para versão nova do Google Maps

Postby José Vicente Beltrán » Mon Feb 03, 2014 8:53 pm

Funciona muy bien,
Gracias por el aporte. :shock:
User avatar
José Vicente Beltrán
 
Posts: 282
Joined: Mon Oct 10, 2005 8:55 am
Location: Algeciras, España

Re: Exemplo de mapa para versão nova do Google Maps

Postby acuellar » Mon Feb 03, 2014 9:46 pm

Gracias SGS

Funciona perfecto.

Saludos,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1645
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Exemplo de mapa para versão nova do Google Maps

Postby karinha » Wed Feb 05, 2014 2:10 pm

Adhemar,

Como hacer para capturar el Zip code - Código postal - ( de una calle )?

Gracias, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Exemplo de mapa para versão nova do Google Maps

Postby Silvio.Falconi » Fri Feb 07, 2014 11:10 am

How show the hotels restaurants... on the map
How make a button to print the map
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Exemplo de mapa para versão nova do Google Maps

Postby vilian » Thu Jan 05, 2017 11:52 pm

Sgs,

Baixei os arquivos mas não funcionou aqui. Apesar de ter colado tudo direto no MED, fica acusando que tem uns caracteres inválidos no conteúdo. Pode me ajudar?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 982
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Exemplo de mapa para versão nova do Google Maps

Postby MGA » Fri Jan 06, 2017 11:01 am

Vilian:

GMAPV3.HTML:

Code: Select all  Expand view  RUN
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Geocoding service</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
      #panel {
        position: absolute;
        top: 5px;
        left: 50%;
        margin-left: -180px;
        z-index: 5;
        background-color: #fff;
        padding: 5px;
        border: 1px solid #999;
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?&v=3.22&sensor=false"></script>
    <script>
var geocoder;
var map;
function initialize() {
  geocoder = new google.maps.Geocoder();
  var latlng = new google.maps.LatLng(-23.347102,-51.979115);
  var mapOptions = {
    zoom: 15,
    center: latlng
  }
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}

function codeAddress() {
  var address = document.getElementById('address').value;
  geocoder.geocode( { 'address': address}, function(results, status) {
    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
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
    }
  });
}
function clickButton(){
    document.getElementById('button').click();
}

    </script>
  </head>
  <input id="address" type="hidden" value="<<STREET>>, <<CITY>>, <<COUNTRY>>">
  <input type="hidden" id="button"  value="Geocode" onclick="codeAddress()">
  <body onload="initialize(); codeAddress('<<STREET>>, <<CITY>>, <<COUNTRY>>')">
    <div id="map-canvas"></div>
  </body>
</html>


gmapv3.prg

Code: Select all  Expand view  RUN
#include "FiveWin.ch"

procedure Main()

   local oDialog, oActiveX
   local cEndereco := PadR( "AV. XV DE NOVEMBRO, 701", 80 )
   local cCidade   := PadR( "MARINGA, PR"            , 80 )
   local cPais     := PadR( "BRASIL"                 , 80 )

   DEFINE DIALOG oDialog RESOURCE "map"

   REDEFINE ACTIVEX oActiveX ID 100 OF oDialog PROGID "Shell.Explorer"
 

   REDEFINE GET cEndereco    ID 200 OF oDialog

   REDEFINE GET cCidade      ID 300 OF oDialog

   REDEFINE GET cPais        ID 400 OF oDialog
   
   REDEFINE BUTTON ID 1 OF oDialog ACTION Show( cEndereco, cCidade, cPais, oActiveX )

   ACTIVATE DIALOG oDialog CENTERED ON INIT Show( cEndereco, cCidade, cPais, oActiveX )

return
/******************************************************************************/
procedure Show( cEndereco, cCidade, cPais, oActiveX )

   local cHtml := MemoRead( "gmapv3.html" )

   cHtml = StrTran( cHtml, "<<STREET>>" , AllTrim( cEndereco ) )
   cHtml = StrTran( cHtml, "<<CITY>>"   , AllTrim( cCidade   ) )
   cHtml = StrTran( cHtml, "<<COUNTRY>>", AllTrim( cPais     ) )

   oActiveX :  Silent := .T.

   MemoWrit( "temp2.html", cHtml )
   
   oActiveX :  Do( "Navigate2", hb_CurDrive() + ":\" + CurDir() + "\temp2.html" )

return
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1254
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Exemplo de mapa para versão nova do Google Maps

Postby vilian » Fri Jan 06, 2017 11:15 am

Obrigado. Agora funcionou perfeito !!

É possível localizar o local por coordenada de GPS ao invés do endereço?
É possível destacar mais de um endereço no mapa ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 982
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Maurizio and 26 guests