ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 GeoMaps Demo & XE6
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
224 Posts

Posted - May 29 2014 :  02:04:31  Show Profile  Reply
I've just downloaded the GeoMaps demo and try to build it using Delphi XE6 and fail with the following:

[dcc32 Fatal Error] iopreviews.pas(2268): F2039 Could not create output file 'C:\Program Files (x86)\ImageEn\DelphiXE6\iopreviews.dcu'


It looks like it's trying to write to the program files and Windows won't let it.

I can't see anything in the code with any filepath references, so maybe its one of the compiler settings is wrong and XE6 is new to me.

Bruce.

bmesser

United Kingdom
224 Posts

Posted - May 29 2014 :  08:29:13  Show Profile  Reply
Transferred the code to a new project and now things are working fine!
Go to Top of Page

masrnet2006

Saudi Arabia
59 Posts

Posted - May 31 2014 :  23:31:03  Show Profile  Reply
unit unit_MainGis_google;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls, XPMan, ComCtrls,MSHTML;
// uses MSHTML;
type
TFmain_unit_MainGis_google = class(TForm)
// XPManifest1: TXPManifest;

WebBrowser1: TWebBrowser;
PanelHeader: TPanel;
pnl_top: TPanel;
LabelAddress: TLabel;
LabelLatitude: TLabel;
LabelLongitude: TLabel;
MemoAddress: TMemo;
Longitude: TEdit;
Latitude: TEdit;
CheckBoxTraffic: TCheckBox;
CheckBoxBicycling: TCheckBox;
CheckBoxStreeView: TCheckBox;
ButtonGotoLocation: TButton;
ButtonGotoAddress: TButton;
btn_open_html: TButton;
btn_go: TButton;
btn_web: TButton;
btn_open_gis: TButton;
btn_file_html_open: TButton;
procedure FormCreate(Sender: TObject);
procedure ButtonGotoLocationClick(Sender: TObject);
procedure ButtonGotoAddressClick(Sender: TObject);
procedure CheckBoxStreeViewClick(Sender: TObject);
procedure CheckBoxBicyclingClick(Sender: TObject);
procedure CheckBoxTrafficClick(Sender: TObject);
procedure btn_open_htmlClick(Sender: TObject);
procedure btn_goClick(Sender: TObject);
procedure btn_webClick(Sender: TObject);
procedure btn_open_gisClick(Sender: TObject);
procedure btn_file_html_openClick(Sender: TObject);
procedure WebBrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
private
HTMLWindow2: IHTMLWindow2;
FIsStartPage: Boolean;
{ Private declarations }
public
procedure AppendToWB(WB: TWebBrowser; const html: widestring) ;
function BrowseURL(const URL: string) : boolean;
procedure WBLoadHTML(WebBrowser: TWebBrowser; HTMLCode: string) ;
{ Public declarations }
end;

var
Fmain_unit_MainGis_google: TFmain_unit_MainGis_google;

implementation
uses
Registry, ShellAPI, ActiveX;

{$R *.dfm}
const
// LOCAL_PAGE ='file:///' +'F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html';
HTMLStr_LOCAL_PAGE ='file:///' +'F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html';
//---------------------------------------------------------------------------------------------------------------------
HTMLStr: string = //i put The code for the web page page wich load the google maps in a string const, you can use an external html file too or embed the page in a resource and then load in a stream
'<html> '+
'<head> '+
'<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" /> '+
'<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> '+
'<script type="text/javascript"> '+
''+
''+//Declare the globals vars to be used in the javascript functions
' var geocoder; '+
' var map; '+
' var trafficLayer;'+
' var bikeLayer;'+
''+
''+
' function initialize() { '+
' geocoder = new google.maps.Geocoder();'+
' var latlng = new google.maps.LatLng(40.714776,-74.019213); '+ //Set the initial coordinates for the map
' var myOptions = { '+
' zoom: 13, '+
' center: latlng, '+
' mapTypeId: google.maps.MapTypeId.ROADMAP '+ //Set the default type map
' }; '+
' map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); '+
' trafficLayer = new google.maps.TrafficLayer();'+ //Create the traffic Layer instance
' bikeLayer = new google.maps.BicyclingLayer();'+ //Create the Bicycling Layer instance
' } '+
''+
''+
' function codeAddress(address) { '+ //function to translate an address to coordinates and put and marker.
' if (geocoder) {'+
' 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 GotoLatLng(Lat, Lang) { '+ //Set the map in the coordinates and put a marker
' var latlng = new google.maps.LatLng(Lat,Lang);'+
' map.setCenter(latlng);'+
' var marker = new google.maps.Marker({'+
' position: latlng, '+
' map: map,'+
' title:Lat+","+Lang'+
' });'+
' }'+
''+
''+
' function TrafficOn() { trafficLayer.setMap(map); }'+ //Activate the Traffic layer
''+
' function TrafficOff() { trafficLayer.setMap(null); }'+
''+''+
' function BicyclingOn() { bikeLayer.setMap(map); }'+//Activate the Bicycling layer
''+
' function BicyclingOff(){ bikeLayer.setMap(null);}'+
''+
' function StreetViewOn() { map.set("streetViewControl", true); }'+//Activate the streeview control
''+
' function StreetViewOff() { map.set("streetViewControl", false); }'+
''+
''+'</script> '+
'</head> '+
'<body onload="initialize()"> '+
' <div id="map_canvas" style="width:100%; height:100%"></div> '+
'</body> '+
'</html> ';
//---------------------------------------------------------------------------------------------------------------------
procedure TFmain_unit_MainGis_google.btn_file_html_openClick(Sender: TObject);

const
LOCAL_PAGE ='F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html';
begin
FIsStartPage := True;
// Webbrowser1.Navigate( 'file:///' +LOCAL_PAGE);
Webbrowser1.Navigate( 'file:///' +LOCAL_PAGE);
FIsStartPage := False;
end;


procedure TFmain_unit_MainGis_google.btn_goClick(Sender: TObject);
var
s: string;
begin
// WebBrowser1.Navigate('http://aspxDelphi.net') ;
// s:= '<a href="http://delphi.about.com">go to About Delphi Programming</a>';
//s:= '<a href="F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html">go to About Delphi Programming</a>';
AppendToWB(WebBrowser1,'gis_delphi.html');
end;

procedure TFmain_unit_MainGis_google.btn_open_gisClick(Sender: TObject);
var
aStream : TMemoryStream;
HTMLStr_new: widestring;
ConStr: widestring;
HTMLFile : Array[0..79] of WideChar;

begin
// HTMLStr_LOCAL_PAGE
// StrPCopy(HTMLFile,HTMLStr_LOCAL_PAGE);
begin
WebBrowser1.Navigate('about:blank'); //Set the location to an empty page
if Assigned(WebBrowser1.Document) then
begin
aStream := TMemoryStream.Create; //create a TStem to load the Page from the string
try
//Usage
// BrowseURL('http:delphi.about.com') ;
// F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html
aStream.WriteBuffer(Pointer(HTMLStr)^, Length(HTMLStr)); //Copy the string to the stream
// aStream.WriteBuffer(Pointer(HTMLFile)^, Length(HTMLFile)); //Copy the string to the stream
//aStream.Write(HTMLStr[1], Length(HTMLStr));
aStream.Seek(0, soFromBeginning);
(WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aStream));//Load the page from the stream
finally
aStream.Free;
end;
HTMLWindow2 := (WebBrowser1.Document as IHTMLDocument2).parentWindow; //Set the instance of the parentWindow to call the javascripts functions
end;
end;
end;

procedure TFmain_unit_MainGis_google.btn_open_htmlClick(Sender: TObject);
var
aStream : TMemoryStream;
HTMLStr_new: widestring;
ConStr: widestring;
HTMLFile : Array[0..258] of WideChar;
begin
// http://theroadtodelphi.wordpress.com/2010/08/07/using-the-google-maps-api-v3-from-delphi-part-i-basic-functionality/
//http://theroadtodelphi.wordpress.com/2010/08/09/using-the-google-maps-api-v3-from-delphi-part-ii-styled-maps/
//http://theroadtodelphi.wordpress.com/2010/08/11/using-google-maps-static-maps-without-twebbrowser/
//HTMLStr
// BrowseURL('http:delphi.about.com') ;
StrPCopy(HTMLFile,'F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html');
// StrPCopy(HTMLFile,'.\gis_delphi.html');

//BrowseURL(HTMLFile) ; // web page

// HTMLStr_new
WebBrowser1.Navigate(HTMLFile); //Set the location to an empty page
// Exit;
//----------------------


//---------------------
// F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html
end;

procedure TFmain_unit_MainGis_google.btn_webClick(Sender: TObject);
var
sHTML,str : string;
str_PAnsiChar:PAnsiChar ;
HTMLFile : Array[0..79] of WideChar;
begin
//sHTML := '<a href="http://delphi.about.com">GOTO</a>' + '<b>About Delphi Programming</b>';
StrPCopy(HTMLFile,'F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html');
WebBrowser1.Navigate(HTMLFile); //Set the location to an empty page
// WBLoadHTML(WebBrowser1,WideCharToString(HTMLFile)) ;
end;

procedure TFmain_unit_MainGis_google.ButtonGotoAddressClick(Sender: TObject);
var
address : string;
begin
address := MemoAddress.Lines.Text;
address := StringReplace(StringReplace(Trim(address), #13, ' ', [rfReplaceAll]), #10, ' ', [rfReplaceAll]);
HTMLWindow2.execScript(Format('codeAddress(%s)',[QuotedStr(address)]), 'JavaScript');//Call the function codeAddress to go the address
end;


procedure TFmain_unit_MainGis_google.ButtonGotoLocationClick(Sender: TObject);
begin
HTMLWindow2.execScript(Format('GotoLatLng(%s,%s)',[Latitude.Text,Longitude.Text]), 'JavaScript');//Call the function GotoLatLng to go the coordinates
end;

procedure TFmain_unit_MainGis_google.CheckBoxBicyclingClick(Sender: TObject);
begin
if CheckBoxBicycling.Checked then
HTMLWindow2.execScript('BicyclingOn()', 'JavaScript')//Activate the Bicycling View option
else
HTMLWindow2.execScript('BicyclingOff()', 'JavaScript');//Deactivate the Bicycling View option
end;

procedure TFmain_unit_MainGis_google.CheckBoxStreeViewClick(Sender: TObject);
begin
if CheckBoxStreeView.Checked then
HTMLWindow2.execScript('StreetViewOn()', 'JavaScript') //Activate the Street View option
else
HTMLWindow2.execScript('StreetViewOff()', 'JavaScript');//Deactivate the Street View option

end;

procedure TFmain_unit_MainGis_google.CheckBoxTrafficClick(Sender: TObject);
begin
if CheckBoxTraffic.Checked then
HTMLWindow2.execScript('TrafficOn()', 'JavaScript')//Activate the Traffic View option
else
HTMLWindow2.execScript('TrafficOff()', 'JavaScript');//Deactivate the Traffic View option
end;

procedure TFmain_unit_MainGis_google.FormCreate(Sender: TObject);
var
aStream : TMemoryStream;

begin

// HTMLStr_LOCAL_PAGE


//HTMLStr_LOCAL_PAGE
// WebBrowser1.Navigate('about:blank'); //Set the location to an empty page
WebBrowser1.Navigate(HTMLStr_LOCAL_PAGE); //Set the location to an empty page
if Assigned(WebBrowser1.Document) then
begin
(*


aStream := TMemoryStream.Create; //create a TStem to load the Page from the string
try
//Usage
// BrowseURL('http:delphi.about.com') ;
// F:\Alhasa.gov.sa\gis_googleMaps\gis_delphi.html

aStream.WriteBuffer(Pointer((HTMLStr))^, Length(HTMLStr)); //Copy the string to the stream
//aStream.Write(HTMLStr[1], Length(HTMLStr));
aStream.Seek(0, soFromBeginning);
(WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aStream));//Load the page from the stream
finally
aStream.Free;
end;
*)
HTMLWindow2 := (WebBrowser1.Document as IHTMLDocument2).parentWindow; //Set the instance of the parentWindow to call the javascripts functions
end;
end;
//----------------

function TFmain_unit_MainGis_google.BrowseURL(const URL: string) : boolean;
var
Browser: string;
begin
Result := True;
Browser := '';
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
Access := KEY_QUERY_VALUE;
if OpenKey('\htmlfile\shell\open\command', False) then
Browser := ReadString('') ;
CloseKey;
finally
Free;
end;
if Browser = '' then
begin
Result := False;
Exit;
end;
Browser := Copy(Browser, Pos('"', Browser) + 1, Length(Browser)) ;
Browser := Copy(Browser, 1, Pos('"', Browser) - 1) ;
ShellExecute(0, 'open', PChar(Browser), PChar(URL), nil, SW_SHOW) ;
end;
//----------
procedure TFmain_unit_MainGis_google.AppendToWB(WB: TWebBrowser; const html: widestring) ;
var
Range: IHTMLTxtRange;
begin
Range := ((WB.Document AS IHTMLDocument2).body AS IHTMLBodyElement).createTextRange;
Range.Collapse(False) ;
Range.PasteHTML(html) ;
end;
//---------------
procedure TFmain_unit_MainGis_google.WBLoadHTML(WebBrowser: TWebBrowser; HTMLCode: string) ;
var
sl: TStringList;
ms: TMemoryStream;
begin
WebBrowser.Navigate('about:blank') ;
while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;

if Assigned(WebBrowser.Document) then
begin
sl := TStringList.Create;
try
ms := TMemoryStream.Create;
try
sl.Text := HTMLCode;
sl.SaveToStream(ms) ;
ms.Seek(0, 0) ;
(WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)) ;
finally
ms.Free;
end;
finally
sl.Free;
end;
end;
end;


procedure TFmain_unit_MainGis_google.WebBrowser1BeforeNavigate2(
ASender: TObject; const pDisp: IDispatch; const URL, Flags, TargetFrameName,
PostData, Headers: OleVariant; var Cancel: WordBool);
var
newURL: string;
begin
newURL := URL;
// For local links, don't show a dialog but open the file directly
if (not FIsStartPage) and FileExists(newURL) then
begin
Cancel := True;
ShellExecute(Application.Handle, 'open', PChar(newURL), nil, nil, SW_NORMAL);
end;
end;

//-------------
end.
//-----------
Go to Top of Page

masrnet2006

Saudi Arabia
59 Posts

Posted - May 31 2014 :  23:33:16  Show Profile  Reply
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">

//Declare the globals vars to be used in the javascript functions
var geocoder;
var map;
var trafficLayer;
var bikeLayer;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(40.714776,-74.019213); //Set the initial coordinates for the map
var myOptions = {
zoom: 13,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP //Set the default type map
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
trafficLayer = new google.maps.TrafficLayer(); //Create the traffic Layer instance
bikeLayer = new google.maps.BicyclingLayer(); //Create the Bicycling Layer instance
}


function codeAddress(address) { //function to translate an address to coordinates and put and marker.
if (geocoder) {
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 GotoLatLng(Lat, Lang) { //Set the map in the coordinates and put a marker
var latlng = new google.maps.LatLng(Lat,Lang);
map.setCenter(latlng);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:Lat+","+Lang
});
}


function TrafficOn() { trafficLayer.setMap(map); } //Activate the Traffic layer

function TrafficOff() { trafficLayer.setMap(null); }

function BicyclingOn() { bikeLayer.setMap(map); } //Activate the Bicycling layer

function BicyclingOff(){ bikeLayer.setMap(null);}

function StreetViewOn() { map.set("streetViewControl", true); } //Activate the streeview control

function StreetViewOff() { map.set("streetViewControl", false); }

</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html> ;
Go to Top of Page

masrnet2006

Saudi Arabia
59 Posts

Posted - May 31 2014 :  23:36:05  Show Profile  Reply
const
LOCAL_PAGE ='c:\gis_delphi.html';
begin
FIsStartPage := True;
// Webbrowser1.Navigate( 'file:///' +LOCAL_PAGE);
Webbrowser1.Navigate( 'file:///' +LOCAL_PAGE);
FIsStartPage := False;
end;
Go to Top of Page

masrnet2006

Saudi Arabia
59 Posts

Posted - Jun 05 2014 :  00:49:36  Show Profile  Reply
ImageEnVect.IO.Params.JPEG_Quality := Quality; // for jpg
ImageEnMView_Main_ms:=TMemoryStream.Create;
// ImageEnVect.IO.SaveToStream(ImageEnMView_Main_ms);
ImageEnVect.IO.SaveToStreamJpeg(ImageEnMView_Main_ms);
ImageEnMView_Main_ms.Position := 0;

str_Count := RDM.ha_InsertQuery(RDM.MainTable_Update, APAGESRL);
ImageEnMView_Main_ms.Free;
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: