Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove / hide the Bing map offline message when offline

I'm developing a Windows Phone app that uses the older WP7 Microsoft.Phone.Controls.Maps.Map / Bing Map control.

The map tiles are being served up from a local source so the app doesn't not need a network connection to work. Unfortunately the map control insists on showing an "Unable to contact Server. Please try again later." message over the map when offline.

Does anyone know of a method to remove / hide this message?

Just in case you're curious - I'm developing a WP8 app but using the depreciated WP7 Bing map control as the new WP8 map control provides no method for replacing the Bing base map.

like image 569
Gavin Avatar asked Jun 05 '13 10:06

Gavin


1 Answers

i think this may suits you better:

void YourPage_Loaded(object sender, RoutedEventArgs e)
        {         
            m_Map.ZoomLevel = 11;          
            m_Map.LayoutUpdated += m_Map_LayoutUpdated; 
        }

        void m_Map_LayoutUpdated(object sender, EventArgs e)
        {
            if (!isRemoved) 
            {
                RemoveOverlayTextBlock();
            }
        }

        void  RemoveOverlayTextBlock()
        {             
            var textBlock = m_Map.DescendantsAndSelf.OfType<TextBlock>()
                           .SingleOrDefault(d => d.Text.Contains("Invalid Credentials") ||
                                                 d.Text.Contains("Unable to contact Server"));
            if (textBlock != null)
            {
                var parentBorder = textBlock.Parent as Border;
                if (parentBorder != null)
                {
                    parentBorder.Visibility = Visibility.Collapsed;
                }
                isRemoved = true;   
            }
       }

You have to include a class LinqToVisualTree witch can be downloaded from here. And here is the original post

like image 148
Swift Sharp Avatar answered Oct 27 '22 01:10

Swift Sharp