How to detect a particular pushpin

Gerhard Faber
05-05-2008, 05:35 AM
Hi,
I want to hold a list of all MP-pushpins in memory. What criteria of the PushPin-Object I added with "AddPushPin" do I have to store in my list, so that I can find the right listentry in "OnSelectionChange"?
I dont' want to use some strings in "Name" or "Note" because the user can change this things.
I tried to store the address of the PushPin-Object, but this didn't work. In "OnSelectionChange" I didn't get the same address as in "AddObject".
greetings
Gerhard

Wilfried
05-05-2008, 08:12 AM
Hi,

Store the address should be the right thing. Are you sure you get 2 different addresses? I try to do a test later today and come back

Wilfried
05-05-2008, 12:59 PM
Hi,

I tryed the following code in a button click:

Location loc = MP.ActiveMap.GetLocation(lat, lon, alt);
Pushpin pp = MP.ActiveMap.AddPushpin(loc, "Wilfried");
thePP = pp;

Then add a few more Pushpins. Then this code in selectionChange:

Pushpin pp = MP.ActiveMap.Selection as Pushpin;
if (pp != null)
if (pp == thePP)
Console.Beep();

It beeps when pp is the same one as the one assigned to thePP with AddPushpin, and it does not when I select others. So this comparistion works good.

Gerhard Faber
05-06-2008, 03:21 AM
Hi Wilfried,
I stored the PushPin in a var with type "IDispache". Now I tried "MapPoint.PushPin" (wich is defiend as "Pushpin = interface(IDispatch)") and my first test was succesfull. (It's Delphi 2006)
At the moment I have to do some other work, so I can't do a complete test. I will come back when i have done this testing...
Thanks
Gerhard

Gerhard Faber
05-08-2008, 03:31 AM
Hi Wilfried,
It works ok if I store the MP-Pbjects (PushPin, Shape) directly without a Typecast.
Thank you very much.
greetings
Gerhard

Wilfried
05-09-2008, 03:24 AM
Hi Gerhard,

Glad it works. Thanks for feedback.

 
Web mp2kmag.com
mapforums.com