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