View Full Version : Easy way to reverse order with code

11-12-2006, 10:11 PM
I have to add locations in a particlar order because I do some calulations between them.
Based on some of the information associated with each location, I will skip over it and not add the location to my map.

At the end of it I need to reverse the order of the locations so that the names and ballons of the first ones added appear on top of the later ones.

Because I don't know the number of locations that my routine added I think that I am looking for some code that would work something like this.

(This is half code and half english)
dim x ,y as int

x = objmap.locations.count (or something like that)

for y = x to 1 '(decending order)
objmap.loc(y) geomove to top
next y

I do not want to set up a route if I can help it.

Can anyone help me?
Philip Macafee (https://plus.google.com/110116137616125452353?rel=author)

11-13-2006, 07:09 AM

There is a ZOrder method to move to top, but I think this only works for shapes. I think you can also use Select() which select your object and I think it will move to top also.

Another possibility is that you keep in your routine a list of the objects that are added to to map. Then you have control from out of your own list.

11-13-2006, 01:49 PM
I did some homework and experimentation with the select method, but I could not figure out how to use it. Could you provide an example?

11-14-2006, 04:42 AM

You have 2 options. If you can hold an array of the pushpins then you can uses your array (it will be the most fast of course). The other option is to use the FindPushpin method, but then you have to have an array with their names.

Pushpin pp = MP.ActiveMap.FindPushpin(name);

Instead of select you can also switch balloon on / off from the pushpins you want:

PP.BalloonState = GeoBalloonState.geoDisplayName;
pp.BalloonState = GeoBalloonState.geoDisplayBalloon;
pp.BalloonState = GeoBalloonState.geoDisplayNone;

11-14-2006, 02:58 PM

I guess I am still not sure how to get on baloon out from under another without removing them.

I have use the following code so far.

(First, get the number of positions)

I want to sequence the points in a reverse order and for-next statements on increase the counter so I add a negative
For xy = -(objmap.DataSets(1).RecordCount) To -1

Here is where I have the problem.
Zorder refers to shapes
GeoOrderBy refers to route waypoints
and datasortorder refers to the underlying data in a data chart.
I can not find a command the will take a pushpin and move it up or down in the sequence or allow me to renumber them.

So this failed:

objPushPin(-(xy)) GeoOrderCmd = "geoBringToFront"
Next xy

Any ideas what to do when I get the pushpin object identified or selected?

11-15-2006, 01:13 PM

I guess I am still not sure how to get on baloon out from under another without removing them.

Just hide the ballons you dont wanna see and display the ones you want the user to see. Waht do you think ? I think it is more easy !

11-20-2006, 01:49 AM

I am beginning to side with you about disappearing the ones that are in the way. The first pushpin has a note balloon with a lot if info and the subsequent pins have just a name. This is a vehicle tracking application, so when a vehicle slows or stops the older information stacks up and covers the most current (1st pushpin) balloon.

I initially used a loop same counter that I did for setting addressing the pushpins. (They are dimmed in an array). But the application senses when the vehicle reports are really close together (probably stopped) so I skip adding the pushpin after finding the location. That make a hole in the array and I was getting errors trying to use the array again. That's why I wanted to detect the presence of the pushpin. Now I think the code should be something like this. Can you assist/comment?

dim pp as Mappoint.pushpin
dim xy as integer
rem: we skip #1, the one we want to show
for xy = 2 to objmap.Datasets(1).Recordcount
pp = objmap.Datasets(1).Item(xy).Pushpin.Select
pp.Balloonstate = geoBalloonStateNone
next xy

11-20-2006, 02:04 PM

I'm not sure I follow. Just have a linked list of all your positions, and a linked list of the visible positions (the ones that has a pushpin).

11-20-2006, 04:54 PM
Yes, you'r right. If I call the recordcount for the Dataset, it will return the pushpin count and not the location count, which had led me down the wrong path. Now I want to step through the pushpin recordset and one by one set the balloon state to none.

I also want to skip position #1 as that is first one at the bottom of the cluster and blocked by the other pushpin names.

That will hide all but the first pushpin I think.

11-21-2006, 07:59 AM

Yes I think that will do it.

11-21-2006, 10:52 PM
Good, can you show me how to step through the pushpins in the dataset and address the ballonstate in each one?

I put some pseudo code in one of the posts above, but I really do not know how.


11-22-2006, 11:44 AM

object o = 1;
RecordSet rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryAllRecords();
while (!rs.EOF) {
switch (rs.Pushpin.BalloonState) {
case GeoBalloonState.geoDisplayBalloon:
Console.WriteLine(rs.Pushpin.Name + " has balloon");
case GeoBalloonState.geoDisplayName:
Console.WriteLine(rs.Pushpin.Name + " has name");
case GeoBalloonState.geoDisplayNone:
Console.WriteLine(rs.Pushpin.Name + " has no balloon");

11-22-2006, 02:22 PM
I am not sure about the actual syntax. My pseudo code above was to illustrate my thinking but probably will not run. Can you show me the steps?

11-22-2006, 02:24 PM
Sorry - posting error!

IE caching issue caused your reply to not show.

11-22-2006, 02:29 PM
Wow, your example allows me to keep the balloons and drop the names and not worry about record numbers!