Jump to content
Fivewin Brasil

Google Maps - Map Location


kapiaba

Recommended Posts

Buenas pueblo, testando este novo exemplo postado no forum inter, que ficou muito bom, eu gostaria de saber, como eu faço para pegar o CEP da Rua? É possivel?



// http://forums.fivetechsupport.com/viewtopic.php?f=6&t=28033

#Include "FiveWin.ch"

PROCEDURE Main()

LOCAL oDlg, oActiveX, oFnt, oFont
LOCAL cEndereco := PadR( "AV. XV DE NOVEMBRO, 701", 80 )
LOCAL cCidade := PadR( "MARINGA, PR" , 80 )
LOCAL cPais := PadR( "BRASIL" , 80 )

DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -14 BOLD

DEFINE DIALOG oDlg RESOURCE "MAP" ;
COLORS CLR_BLACK, CLR_WHITE

oDlg:lHelpIcon := .F.

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

REDEFINE GET cEndereco ID 200 OF oDlg ;
COLORS CLR_HBLUE, CLR_WHITE

REDEFINE GET cCidade ID 300 OF oDlg ;
COLORS CLR_HBLUE, CLR_WHITE

REDEFINE GET cPais ID 400 OF oDlg ;
COLORS CLR_HBLUE, CLR_WHITE

REDEFINE BUTTON ID 1 OF oDlg ;
ACTION Show( cEndereco, cCidade, cPais, oActiveX ) CANCEL

SET FONT OF oDlg TO oFont

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

oFont:End()

RETURN NIL

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

LOCAL cHtml := MemoRead( "gmapd2.html" )

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

MemoWrit( "temp.html", cHtml )

// Harbour
//oActiveX : Do( "Navigate2", hb_CurDrive() + ":\" + CurDir() + "\temp.html" )
// xHarbour
oActiveX:Do( "Navigate2", CurDrive() + ":\" + CurDir() + "\temp.html" )

RETURN NIL

// GMAPD2.HTML:

/*
<!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%;
;
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>
*/

/*
//gmapd2.rc

1 24 "winxp/WindowsXP.Manifest"
#include <windows.h>

MAP DIALOG 66, 64, 418, 252
STYLE DS_ABSALIGN | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Map location - Localização no Mapa"
FONT 8, "MS Sans Serif"
{
CONTROL "", 100, "TActiveX", 0 | WS_CHILD | WS_VISIBLE, 4, 5, 409, 191
LTEXT "Rua e Número:", -1, 5, 201, 80, 8
EDITTEXT 200, 5, 212, 189, 12
LTEXT "Cidade:", -1, 5, 227, 40, 8
EDITTEXT 300, 5, 236, 92, 12
LTEXT "Pais:", -1, 103, 227, 40, 8
EDITTEXT 400, 103, 236, 91, 12
DEFPUSHBUTTON "&Busca", IDOK, 207, 223, 50, 14
PUSHBUTTON "&Saida", 2, 263, 223, 50, 14
}
*/


Obg. Abs.

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...