Page 1 of 1

OnClick: Which marker is selected?

PostPosted: 27 Oct 2013 09:59
by FrancescoPierobon
With JQUeryDemo_V2, TIWCGJQGMap3 example, function MultiMarkers: is there a way to know on which marker the user has put the mouse if the event MultiMarkerMouseOverEvent is fired?

Thank you very much for your help.

Re: OnClick: Which marker is selected?

PostPosted: 28 Oct 2013 11:01
by Alexander Bulei
Hi FrancescoPierobon,

With JQUeryDemo_V2, TIWCGJQGMap3 example, function MultiMarkers: is there a way to know on which marker the user has put the mouse if the event MultiMarkerMouseOverEvent is fired?


Yes, you can,

  1. You need set "ID" for marker.

    Example:

    delphi code
    LMarker:= Marker.Values.Add;
    LMarker.Id:= 'mymarkerID_2'; // unique ID
    LMarker.Data:= 'Mealhada';
    LMarker.LatLng.Latitude:= 40.36267630;
    LMarker.LatLng.Longitude:= -8.453534200000002;

  2. Add new BrowserParam to event:

    Example:

    delphi code
    procedure TIWForm1.IWAppFormCreate(Sender: TObject);
    var
    LMarker: TIWCGJQGMap3MultipleMarker;
    begin
    with IWCGJQGMap3.JQGMapV3Options do
    begin
    Map.Options.Zoom:= 6;
    Map.Options.Center.Latitude:= 40.36267630;
    Map.Options.Center.Longitude:= -8.453534200000002;
    Map.Options.Draggable:= False;
    {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;
    end;
    end;

  3. To get the marker id, do this in MouseOver event:

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



Best Rgeards.

Re: OnClick: Which marker is selected?

PostPosted: 28 Oct 2013 16:04
by FrancescoPierobon
Hi CGDevTools,

Thank you very much for your great support that will distinguish from others and for which it is really worth to invest on your components.

Francesco Pierobon
http://www.webcolf.com

Re: OnClick: Which marker is selected?

PostPosted: 28 Mar 2019 16:33
by FredT
Hi,

I would like do the same thing with the event "OnDragEnd" but it doesn't work, the event is not fired !

LMarker:= IWCGJQGMap3.JQGMapV3Options.Marker.Values.Add;
LMarker.Data:= 'Marker 0';
LMarker.Id := '0';
LMarker.LatLng.Latitude:= 0;
LMarker.LatLng.Longitude:= 0;
LMarker.Options.Draggable := True;

with IWCGJQGMap3.JQGMapV3Options.Marker.Events.OnDragEnd.BrowserParams.Add do
begin
ServerName := 'markerid';
BrowserScript := 'context.id';
end;

Thank

Re: OnClick: Which marker is selected?

PostPosted: 29 Mar 2019 12:03
by Alexander Bulei
Hi FredT,

Check our main demo, it have example of dragend event.

Best Regards.

Re: OnClick: Which marker is selected?

PostPosted: 29 Mar 2019 17:29
by FredT
Hi,

Yes, that's what I did! But in the example there are no additional parameters.
But it is when I add one (to find the marker's id) that the event is no longer called!

Thank.

Re: OnClick: Which marker is selected?

PostPosted: 01 Apr 2019 09:24
by Alexander Bulei
Hi,

Because you have javascript error.

with IWCGJQGMap3.JQGMapV3Options.Marker.Events.OnDragEnd.BrowserParams.Add do
begin
ServerName := 'markerid';
BrowserScript := 'context.id';
end;


The function doesnt have any "context" parameter, only "marker".

Best Regards.

Re: OnClick: Which marker is selected?

PostPosted: 01 Apr 2019 14:17
by FredT
Hi,

I admit that I did not understand much about the operation of additional parameters for events. I did not find any documentation on this subject either, so:

1- How do we know that OnMouseOver has a Context parameter and not OnDragEnd?

2 - By extension, how to know the parameters usable for each event?

3 - And especially what BrowserScript should I use in OnDragEnd?
Because if I do not put BrowserScript in OnDragEnd, I get an empty string in markerid.
Same if I enter BrowserScript: = 'marker.id';
And if I put something else, the event is no longer called!

Thank.

Re: OnClick: Which marker is selected?

PostPosted: 01 Apr 2019 16:06
by Alexander Bulei
Hi FredT,

viewtopic.php?f=5&t=3843

Best Regards.

Re: OnClick: Which marker is selected?

PostPosted: 02 Apr 2019 10:22
by FredT
Hi Alexander,

Thank you so much.