Alexandr
Alexandr

Reputation: 1901

How clear all Pushpin on Map on Windows Phone 7?

I want to clear all a Pushpin on Map. I can use map.Children.Clear(), it's work good. But I work with google maps and use this XAML code:

<my:Map Height="756" HorizontalAlignment="Left" Margin="12,6,0,0" Name="googlemap"
                   CredentialsProvider="AqayajnZU8FSfDGL8jpK5zMKAHmUL27Uqxv_OnpQzJQOI2PoQyxcG7dlR6_g4WWo" 
                   CopyrightVisibility="Collapsed" LogoVisibility="Collapsed" 
                   ScaleVisibility="Visible"  VerticalAlignment="Top" Width="438" >
                <my:Map.Mode>
                    <MSPCMCore:MercatorMode/>
                </my:Map.Mode>
                <my:MapTileLayer Name="street" Margin="0,0,0,32" Height="800" Width="433">
                    <my:MapTileLayer.TileSources>
                        <GoogleTileSource:GoogleTile TileTypes="Street"/>
                    </my:MapTileLayer.TileSources>
                </my:MapTileLayer>
            </my:Map>

So, when I call map.Children.Clear() then MapTileLayer removed too. How I can remove only Pushpin?

Any ideas.

Upvotes: 1

Views: 875

Answers (1)

Igor Kulman
Igor Kulman

Reputation: 16361

Iterate through all the children and remove only the ones that are of type Pushpin

foreach (var item in googlemap.Children.ToList())
{
    if (item is MapTileLayer) continue;
    googlemap.Children.Remove(item);
 }

Upvotes: 1

Related Questions