CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

How to see which marker is clicked on Gmap3

by PeterSondergaard » 09 Aug 2018 09:15

Hi

I have found an old post in JQCMap called "OnClick: Which marker is selected?"
I have tried to implement the solution without much luck. (I have converted the example to C++)

Every time I add the extra BrowserParams does the EventMouseOver not fire.
If I remove the BrowserParams does it fire correctly.

Can you tell me what I do wrong.

Here is my code:

//---------------------------------------------------------------------------
void __fastcall TIWForm2::IWCGJQGMap31JQGMapV3OptionsMarkerEventsMouseOver(TObject *Sender,
TStringList *AParams)
{
String MyMarkerId;

IWCGJQGMap3->JQGMapV3Options->InfoWindow->Options->ContentFunc->Script = IWCGJQGMap3->CurrEventParamsJs(2,'data');
IWCGJQGMap3->JQGMapV3Options->InfoWindow->Anchor->Script = IWCGJQGMap3->CurrEventParamsJs(0);
IWCGJQGMap3->JQGMapV3Options->InfoWindow->ApplyProps();

MyMarkerId = AParams->Values["markerid"];

// Do my stuff with MyMarkerId...
}
//---------------------------------------------------------------------------
void __fastcall TIWForm2::IWCGJQGMap31JQGMapV3OptionsMarkerEventsMouseOut(TObject *Sender,
TStringList *AParams)
{
IWCGJQGMap3->JQGMapV3Options->InfoWindow->Close();
}
//---------------------------------------------------------------------------
void __fastcall TIWForm2::IWButton1Click(TObject *Sender)
{
TIWCGJQGMap3MultipleMarker *LMarker;
TIWCGBrowserParam *BP;

IWCGJQGMap3->JQGMapV3Options->Map->Options->Zoom = 3;
IWCGJQGMap3->JQGMapV3Options->Map->Options->Center->Latitude = 40.36267630;
IWCGJQGMap3->JQGMapV3Options->Map->Options->Center->Longitude = -8.453534200000002;
IWCGJQGMap3->JQGMapV3Options->Map->Options->MapTypeControl = true;
IWCGJQGMap3->JQGMapV3Options->Map->Options->MapTypeControlOptions->Style = gmmtcsDropDownMenu;

IWCGJQGMap3->JQGMapV3Options->Marker-> Values->Clear();

// LISBON
LMarker = IWCGJQGMap3->JQGMapV3Options->Marker->Values->Add ();
LMarker->Data = "Lisbon, Portugal";
LMarker->LatLng->Latitude = 38.72529930;
LMarker->LatLng->Longitude = -9.150036400000001;
LMarker->Id = "mymarkerID_1";
BP = LMarker->Events->OnMouseOver->BrowserParams->Add();
BP->ServerName = "markerid";
BP->BrowserScript = "context.id";

// MADRID
LMarker = IWCGJQGMap3->JQGMapV3Options->Marker->Values->Add ();
LMarker->Data = "Madrid, Spain";
LMarker->LatLng->Latitude = 40.416775;
LMarker->LatLng->Longitude = -3.703790;
LMarker->Id = "mymarkerID_2";
BP = LMarker->Events->OnMouseOver->BrowserParams->Items-> Add();
BP->ServerName = "markerid";
BP->BrowserScript = "context.id";
}
//---------------------------------------------------------------------------
PeterSondergaard
 
Posts: 12
Joined: 02 Jun 2014 13:56

by Alexander Bulei » 10 Aug 2018 15:36

Hi PeterSondergaard,

You're adding the markers on async (IWButton1Click), and I don't see the ajaxrender...unless the code is incomplete.
Also, check the delphi code below, you need assing the event to your LMarker.

delphi code
procedure TIWMainForm.IWCGAppFormCreate(Sender: TObject);
var
LMarker: TIWCGJQGMap3MultipleMarker;
begin
with IWCGJQGMap31.JQGMapV3Options do
begin
Map.Options.Zoom:= 6;
Map.Options.Center.Latitude:= 40.36267630;
Map.Options.Center.Longitude:= -8.453534200000002;
{MEALHADA}
LMarker:= Marker.Values.Add;
LMarker.Id:= 'mymarkerID_2';
LMarker.Data:= 'Mealhada';
LMarker.LatLng.Latitude:= 40.36267630;
LMarker.LatLng.Longitude:= -8.453534200000002;
with LMarker.Events.OnMouseOver.BrowserParams.Add do
begin
ServerName:= 'markerid';
BrowserScript:= 'context.id';
end;
LMarker.Events.OnMouseOver.OnEvent:= MarkerEventsMouseOver;
end;
end;

procedure TIWMainForm.MarkerEventsMouseOver(Sender: TObject; AParams: TStringList);
var
MyMarkerId: string;
begin
MyMarkerId:= AParams.Values['markerid'];
{ your code here }
end;


Best Reagrds.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal


Return to JQGMap3

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.