Pushpins not dissapearing when behind globe

Aug 18, 2011 at 12:35 PM
Edited Aug 18, 2011 at 12:55 PM

I have created a custom pushpin and would like them to disappear when behind the globe. However, at the moment they don't. I have looked at the source for the VEPushPin (which my custom pin inherits from) and the code seems to suggest it should disappear when behind the globe. If this is correct is there a particular way you set pushpins or custom pushpins to dissapear when behind the globe?


Edit: I uncommented the line in VEPushPin.cs: 

//Not animating, just hide immediately
this.Visibility = Visibility.Collapsed;

But now, the pins that should be hidden are pulsating, Ive debugged and something is setting them to hidden and then back to visible.




Aug 20, 2011 at 5:40 AM

If a pushpin's latlong is behind the planet, the call to

GetPosition(VELatLong latLong, out VEPushPinAltitudeEvent altEvent, out bool isVisible)

will return with isVisible set to false. (Several other conditions cause isVisible to be false as well.)

This is primarily used in

public override Point? UpdatePosition(VEMap map)

If you are overriding this method you'll need to either call base.UpdatePosition(map) or provide similar logic. I'm guessing you already know all this though, but maybe it will help as you debug it.

FYI the call to this.Map.IsBehindPlanet(latLong) is relatively expensive, which is why it is throttled to every 10 frames. This allows better performance with more pushpins, assuming the whole thing is working at all. ;) How many pushpins are you databinding at one time?

Are the standard VEPushPins working properly? If so, it may just be a matter of working backwards from your customizations to isolate which change caused the behavior change.

Aug 25, 2011 at 10:35 AM
Edited Aug 25, 2011 at 10:44 AM

Hey Josh,

Thanks for your reply, I have it all working perfectly now, I commented out this line of code in VEPushPin.cs


//Not visible if behind planet
//if (behindPlanetCheckCount++ > behindPlanetCheckMax)
      //behindPlanetCheckCount = 0;

      if (this.Map.IsBehindPlanet(latLong))
          isVisible = false;

The if statement checking that whether the behindplanet pushpin count was higher than the max (that was set to 10) was always coming back as true as 

we have about 150 pushpins on the globe, which are written dynamically onto the globe from an external datasource and the count is constantly changing, 

and is therefore impossible to tell how many the max should be. This was causing the count to always be set to 0 so making all pins visible, whether behind the planet or not.

After removing that if statement and not having a limit to how many can be behind the planet, everything started to work fine :)

Thanks again for your help!