AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte Google Maps über COM (Component Object Model)
Thema durchsuchen
Ansicht
Themen-Optionen

Google Maps über COM (Component Object Model)

Ein Thema von Thom · begonnen am 23. Dez 2010 · letzter Beitrag vom 22. Mai 2022
 
azrin.aris

Registriert seit: 25. Dez 2011
3 Beiträge
 
#10

AW: Google Maps über COM (Component Object Model)

  Alt 28. Dez 2011, 22:17
Hi all,

Here is another stumbling block that I encounter

the delphi code is:
Delphi-Quellcode:
procedure TForm1.InitMap(Sender: TObject);
var
  Marker: TMarker;
  MarkerOptions: TMarkerOptions;
  MyMap: TMap;
  MyOptions: TMapOptions;
begin
  with TScript(Sender) do
  begin
    MyOptions:=TMapOptions.Create;
    with MyOptions do
    begin
      Zoom:=4;
      Center:=New(Google.Maps.LatLng(-25.363882,131.044922));
      MapTypeID:=Google.Maps.MapTypeID.Roadmap;
    end;
    MyMap:=New(Google.Maps.Map(MyOptions));
    MarkerOptions:=TMarkerOptions.Create;
    with MarkerOptions do
    begin
      Position:=MyMap.GetCenter;
      Map:=MyMap;
      Title:='Click to zoom';
    end;
    Marker:=New(Google.Maps.Marker(MarkerOptions));
    {$IFDEF USE_ANONYMOUS_METHODS}
    Marker.OnClick:=
      procedure(Sender: TObject; Event: TEvent)
      begin
        if MyMap.GetZoom=8
          then MyMap.SetZoom(4)
          else MyMap.SetZoom(8);
        MyMap.SetCenter(Marker.GetPosition);
      end;
    {$ELSE}
    Marker.OnClick:=MarkerClick;
    {$ENDIF}
  end;
end;

{$IFNDEF USE_ANONYMOUS_METHODS}
procedure TForm1.MarkerClick(Sender: TObject; Event: TEvent);
begin
  with Script do
  begin
    if Maps[0].GetZoom=8
      then Maps[0].SetZoom(4)
      else Maps[0].SetZoom(8);
    Maps[0].SetCenter(TMarker(Sender).GetPosition);
  end;
end;
{$ENDIF}
and the C++ code is:
Code:
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <SHDocVw.hpp>
#include <Vcl.OleCtrls.hpp>
#include "gmAPI.hpp"
#include "gmMap.hpp"
#include "gmOverlaysMarker.hpp"
#include "gmEvents.hpp"
#include "HTMLObjects.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:   // IDE-managed Components
    TWebBrowser *WebBrowser1;
    void __fastcall FormCreate(TObject *Sender);
private:   // User declarations
    TScript *Script;
    void __fastcall InitMap(TObject *Sender);

public:       // User declarations
    __fastcall TForm1(TComponent* Owner);

    void __fastcall MarkerClick(TObject* Sender, Gmevents::TEvent Event);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif



//Unit1.cpp

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

#pragma link "gmMap"
#pragma link "winInet.lib"

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   Script = new TScript(WebBrowser1);
   Script->LoadAPIAsync(InitMap);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::InitMap(TObject *Sender)
{

   int n;
   TMarker *Marker;
   TMarkerOptions *MarkerOptions;
   TLatLng *MyLatLng;
   TMap *MyMap;

   TScript *Script = dynamic_cast<TScript*>(Sender);

   TMapOptions *MyOptions = new TMapOptions;

   MyOptions->Zoom = 4;
   MyOptions->Center = Script->Google->Maps->LatLng(-25.363882,131.044922);
   MyOptions->MapTypeID = Script->Google->Maps->MapTypeID->Roadmap;

   MyMap = Script->Google->Maps->Map(MyOptions);

   MarkerOptions = new TMarkerOptions;

   MarkerOptions->Position = MyMap->GetCenter();
   MarkerOptions->Map      = MyMap;
   MarkerOptions->Title   = "Click to Zoom";
   Marker = Script->Google->Maps->Marker(MarkerOptions);
   Marker->OnClick = MarkerClick;  //[BCC32 Error] Member function must be called or its address taken

   delete MyOptions;
   delete MarkerOptions;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::MarkerClick(TObject* Sender, Gmevents::TEvent Event)
{
   if(Script->Google->Maps[0]->GetZoom==8) // Error :E2288 Pointer to structure required on left side of -> or ->*
   {

   }
}
//---------------------------------------------------------------------------

I could not get the MarkerClick to be assigned to Marker->OnClick.

Also I could not find the Script->Google->Maps[0]->GetZoom() function.

Attached is the hpp file converted by C++ Builder


Anyhelp would be very much appreciated.

Thank you
Angehängte Dateien
Dateityp: zip gmAPI.zip (6,1 KB, 57x aufgerufen)

Geändert von azrin.aris (28. Dez 2011 um 22:34 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

(?)

LinkBack to this Thread

Erstellt von For Type Datum
DELPHI | (google maps) This thread Refback 11. Nov 2011 09:07
Twebbrowser HTML tag to UniHTMLFrame1 - uniGUI Discussion Forums This thread Refback 4. Nov 2011 06:52
DoraDev1975: google maps This thread Refback 23. Sep 2011 08:18
delphi osm - Google Search Post #0 Refback 19. Sep 2011 09:02
DoraDev1975: ?&#3636;????? 2011 This thread Refback 11. Sep 2011 16:39
DoraDev1975 This thread Refback 30. Aug 2011 10:13
Untitled document This thread Refback 25. Jun 2011 19:57
Interact with Google Maps in a TWebBrowser from Delphi | Ramblings This thread Refback 26. Jan 2011 05:12
google maps mit delphi link - Google Search This thread Refback 24. Jan 2011 14:24
google maps mit delphi - Google Search This thread Refback 24. Jan 2011 14:20
Untitled document This thread Refback 19. Jan 2011 21:49

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz