none
Black boxes are appearing in Map RRS feed

  • Question

  • Hi,

    In my C# Metro Ui App I have the functionality of displaying a location in Bing Map.

    A very strange thing is happening though.

    I can display the map , I can display the location (note - I'm using a basic key) , I can display the pin , but I see a lot of blank spots in the map.

    What are these black boxes that I'm seeing ?

    How can I get rid off these black boxes ?

    Appreciate any help you could give me

    thank you

    Friday, January 4, 2013 1:40 PM

Answers

  • Hi ,

    After the update I've just downloaded this one is fixed.

    Everything is OK now.

    thanks Microsoft

    • Marked as answer by zakkar Friday, February 8, 2013 10:31 AM
    Friday, February 8, 2013 10:31 AM

All replies

  • A picture or repro will assist me in answering this question.
    Monday, January 7, 2013 5:28 PM
  • Hi ,

    It is not happening in the simulator but in my tablet.

    I am creating a point in the map so when the user clicks on it ,I'm displaying a popup window which  some information appears to the user. An address whatever.

    When I tap somewhere else almost all of my map fills with black spots.

    If you take a closer look I have a point (1) in my map. When I click it , I'm displaying the black box  which contains the information.

    Take a closer look in the surrounding area . Black rectangular are appearing.

    It gets worse. If I press the zoom for a closer look , then this black shade becomes completely black and the roads fills with black color.

    Any ideas ?

    Perhaps If you create a pushpin and in the tap event display some information maybe you can reproduce it.

    Any ideas ?

    Thank you



    • Edited by zakkar Tuesday, January 8, 2013 12:17 PM
    Tuesday, January 8, 2013 12:16 PM
  • This looks like a graphics driver bug. If you can provide a repro I'm happy to validate it on a local machine.
    Tuesday, January 8, 2013 5:07 PM
  • I'm not sure what are you asking me to do.

    DO you want me to send you some  code ?

    This happens in my surface tablet.


    • Edited by zakkar Wednesday, January 9, 2013 6:33 AM
    Wednesday, January 9, 2013 6:27 AM
  • Yes, code that reproduces this problem is necessary for us to investigate this.
    Wednesday, January 9, 2013 5:44 PM
  • OK.

    This is the code that I use. The Job.LocationData()  is a class which contains the below attributues

     public class LocationData
            {
                public LocationData()
                {
                }

                public string Name { get; set; }
                public double Latitude { get; set; }
                public double Longitude { get; set; }
                public double Accurancy { get; set; }
                public string Querry { get; set; }
                public string Address { get; set; }
            }

    and this is the code 

    using Bing.Maps;
    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Runtime.Serialization.Json;
    using System.Threading;
    using System.Threading.Tasks;
    using Windows.Devices.Geolocation;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Imaging;
    using Windows.UI.Xaml.Navigation;
    
    
    
    namespace myproject
    {
        /// <summary>
        /// A basic page that provides characteristics common to most applications.
        /// </summary>
        public sealed partial class MapLocation : Myproject.Common.LayoutAwarePage
        {
            private Geolocator _geolocator = null;
            private CancellationTokenSource _cts = null;
            private Callisto.Controls.Flyout Mypopup = null;
            
           
           string sessionKey = "mysession key";
         
    
            public MapLocation()
            {
                this.InitializeComponent();
                _geolocator = new Geolocator();
              
    
            }
    
            
            /// <summary>
            /// Populates the page with content passed during navigation.  Any saved state is also
            /// provided when recreating a page from a prior session.
            /// </summary>
            /// <param name="navigationParameter">The parameter value passed to
            /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
            /// </param>
            /// <param name="pageState">A dictionary of state preserved by this page during an earlier
            /// session.  This will be null the first time a page is visited.</param>
            protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
            {
            }
    
            /// <summary>
            /// Preserves state associated with this page in case the application is suspended or the
            /// page is discarded from the navigation cache.  Values must conform to the serialization
            /// requirements of <see cref="SuspensionManager.SessionState"/>.
            /// </summary>
            /// <param name="pageState">An empty dictionary to be populated with serializable state.</param>
            protected override void SaveState(Dictionary<String, Object> pageState)
            {
            }
    
            void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
            {
                this.Map.Width = (Int32)e.Size.Width;
                this.Map.Height = (Int32)e.Size.Height;
    
            }
    
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
    
                base.OnNavigatedTo(e);
                this.Loaded += Messages_Loaded;
                Window.Current.SizeChanged += Current_SizeChanged;
                
                if (Mypopup != null)
                {
                    Mypopup.IsOpen = false;
                    Mypopup.Dispose();
                    Mypopup = null;
    
                }
    
            
    
             
                MapLocationButton.IsEnabled = true;
                CancelGetLocationButton.IsEnabled = false;
           //the Mydata.Querry is  a string which contains the address I'm searching.Just a string
    
              ConnectToWebService(MyData.Querry);
                         
              
               
    
    
    
            }
    
    
            private void Messages_Loaded(object sender, RoutedEventArgs e)
            {
                this.Map.Width = (Int32)this.ActualWidth;
                this.Map.Height = (Int32)this.ActualHeight;
            }
    
            public void InitializeMap()
            {
                // reset credentials following the invalid/missing credentials test cases.
                if (this.Map.Credentials != this.sessionKey)
                {
                    this.Map.Credentials = this.sessionKey;
                }
    
               // this.Map.Culture = "en-US";
               // this.Map.Center = new Bing.Maps.Location(MyCurrentPosition.Latitude, MyCurrentPosition.Longitude);
                this.Map.Center = new Bing.Maps.Location(0, 0);
                this.Map.ZoomLevel = 2;
                this.Map.MapType = MapType.Road;
                this.Map.ShapeLayers.Clear();
                this.Map.ShowScaleBar = true;
                this.Map.ShowTraffic = false;
                this.Map.SuppressNetworkRequests = false;
                this.Map.TileLayers.Clear();
                this.Map.Children.Clear();
                
            }
            
        
    
            protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
            {
               
    
                if (Mypopup != null)
                {
                    Mypopup.IsOpen = false;
                    Mypopup.Dispose();
                    Mypopup = null;
    
                }
             
                Window.Current.SizeChanged -= Current_SizeChanged;
             
                base.OnNavigatingFrom(e);
            }
    
           
    
            private void AddPin(Double Latitude, Double Longitude, Double Accurancy , string mystring , string address)
            {
                Pushpin MyPushpin = new Pushpin();
                MyPushpin.Width = 65;
                MyPushpin.Height = 65;
                MyPushpin.Text = mystring;
    
                Job.LocationData Mydata = new Job.LocationData();
                Mydata.Name = mystring;
                Mydata.Latitude = Latitude;
                Mydata.Longitude = Longitude;
                Mydata.Accurancy = Accurancy;
                Mydata.Address = address;
                MyPushpin.DataContext = Mydata;
              
                MyPushpin.Tapped += MyPushpin_Tapped;
                //Image MyImage = new Image();
                //MyImage.Width = 65;
                //MyImage.Height = 65;
                //MyImage.Source = ImageFromRelativePath(this, "../Assets/pin.png");
                MapLayer.SetPosition(MyPushpin, new Bing.Maps.Location(Latitude, Longitude));
                MapLayer.SetPositionAnchor(MyPushpin, new Windows.Foundation.Point(30,30));
           
                Map.Children.Add(MyPushpin);
    
          
            
            }
    
            void MyPushpin_Tapped(object sender, TappedRoutedEventArgs e)
            {
    
                Pushpin myPushpin = sender as Pushpin;
                if (myPushpin==null)  return ;
                Job.LocationData Mydata = new Job.LocationData();
                Mydata = (Job.LocationData)myPushpin.DataContext;
                if (Mydata == null) return;
                StackPanel s = new StackPanel();
    
                TextBlock Mytext = new TextBlock() { TextWrapping = TextWrapping.Wrap };
    
                Mytext.Foreground = new SolidColorBrush(Colors.White);
                Mytext.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
                Mytext.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
                Mytext.MaxHeight = 500;
                Mytext.TextWrapping = TextWrapping.Wrap;
                Mytext.MaxWidth = 500;
                Mytext.FontSize = 18;
                Mytext.Margin = new Thickness(4);
                if (Mydata.Address != null && Mydata.Address.Trim() != "")
                {
                    Mytext.Text = Mydata.Name + "\r\n" + "Address:" + Mydata.Address +"\r\n" + "Latidute:" + Mydata.Latitude.ToString() + "\r\n" + "Longitude:" + Mydata.Longitude.ToString() + "\r\n" + "Accurancy:" + Mydata.Accurancy.ToString();
    
                }
                else
                {
                    Mytext.Text = Mydata.Name + "\r\n" + "Latidute:" + Mydata.Latitude.ToString() + "\r\n" + "Longitude:" + Mydata.Longitude.ToString() + "\r\n" + "Accurancy:" + Mydata.Accurancy.ToString();
                }
               
                s.Children.Add(Mytext);
                
                Mypopup = new Callisto.Controls.Flyout();
                Mypopup.Background = (Brush)App.Current.Resources["AppBarItemPressedForegroundThemeBrush"];
                // Flyout is a ContentControl so set your content within it.
                Mypopup.Content = s;
    
                Mypopup.Placement = PlacementMode.Top;
                Mypopup.PlacementTarget = sender as UIElement; // this is an UI element (usually the sender)
                Mypopup.MaxHeight = 400;
    
                Mypopup.IsOpen = true;
                Mypopup.Closed += Mypopup_Closed;
            }
    
            void Mypopup_Closed(object sender, object e)
            {
                if (Mypopup != null)
                {
                    Mypopup.Closed -= Mypopup_Closed;
                }
    
            }
    
            async void ConnectToWebService(string mystring)
            {
                if (this.LocationDataCollection == null)
                {
                    LocationDataCollection = new List<Job.LocationData>();
    
                }
                else
                {
                    LocationDataCollection.Clear();
              
                }
    
                InitializeMap();
    
             
                        
    
                string query = mystring;
    
                Uri geocodeRequest = new Uri(string.Format("http://dev.virtualearth.net/REST/v1/Locations?q={0}&key={1}", query, sessionKey));
                //Make a request and get the response
                Response r = await GetResponse(geocodeRequest);
    
    
                if (r.StatusCode == 200)
                {
                    ProcessResponse(r);
                
                }
                
            }
    
    
           private void ProcessResponse(Response locationsResponse)
            {
                int locNum = locationsResponse.ResourceSets[0].Resources.Length;
    
                //Get formatted addresses
                //Get all locations in the response and then extract the formatted address for each location
               
              // List<Bing.Maps.Location> locations = new List<Bing.Maps.Location>();
    
                for (int i = 0; i < locNum; i++)
                {
                    Location location = (Location)locationsResponse.ResourceSets[0].Resources[i];
                    if (location.Confidence == "High")
                    {
                          int geocodePointNum = location.GeocodePoints.Length;
                          for (int j = 0; j < geocodePointNum; j++)
                          {
                              if (j == 0) continue;
    
    
                              double latidute = location.GeocodePoints[j].Coordinates[0];
                              double longtidute = location.GeocodePoints[j].Coordinates[1];
    
                              Bing.Maps.Location Binglocation = new Bing.Maps.Location(latidute, longtidute);
    
                              double zoomLevel = 13.0f;
    
                              Map.SetView(Binglocation, zoomLevel);
    
                              // Display the location information in the textboxes.
                              LatitudeTextbox.Text = latidute.ToString();
                              LongitudeTextbox.Text = longtidute.ToString();
                              AccuracyTextbox.Text = "0";
    
    
                              Job.LocationData MyData = new Job.LocationData();
                              MyData.Name = "A";
                              MyData.Longitude = longtidute;
                              MyData.Latitude = latidute;
                              MyData.Accurancy = 0;
                              MyData.Address = location.Address.FormattedAddress;
                              MyCurrentPosition = MyData;
    
                              LocationDataCollection.Add(MyData);
                          
                              this.AddPin(latidute, longtidute, 0, j.ToString(), MyData.Address);
                           // break;
                          }
                    
                    }
    
                   
    
    
    
                }
             
            }
    
    
    
    
            private async Task<Response> GetResponse(Uri uri)
            {
                System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                var response = await client.GetAsync(uri);
                using (var stream = await response.Content.ReadAsStreamAsync())
                {
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Response));
                    return ser.ReadObject(stream) as Response;
                }
            }
    
            public BitmapImage ImageFromRelativePath(FrameworkElement parent, string path)
            {
                var uri = new Uri(parent.BaseUri, path);
                BitmapImage result = new BitmapImage();
                result.UriSource = uri;
                return result;
            }
    
    
            //private void buttonAddImagePin_Click(object sender, RoutedEventArgs e)
            //{
            //    // Create Regular Image Bitmap
            //    Image img = new Image();
            //    img.Width = 65;
            //    img.Height = 65;
            //    img.Source = new BitmapImage(new Uri("ms-appx:///Images/PinImage.png"));
    
            //    // Get the maps current center location (that's where im going to place the image)
            //    Location CurrentMapCenterLocation = MainPageBingMap.Center;
    
            //    // Add image to map layer
            //    defaultMapLayer.Children.Add(img);
    
            //    // Set location on map layer
            //    // Note:    In SetPositionAnchor 65 represents is the image size, anchor requires us to take that 
            //    //          into account and divide by 2 if we want to use the center point of the image as the anchor
    
            //    // Places image on the map layer at a specific lat/long
            //    MapLayer.SetPosition(img, CurrentMapCenterLocation);
    
            //    // Locks the image with an Anchor pointer in the center of the image to prevent it from moving during map zoom
            //    MapLayer.SetPositionAnchor(img, new Point(img.Width / 2, img.Height / 2));
            //}
    
    
    
    
        }
    }
    

    I have removed from the above some instances or changed a little bit the code but it will give you an idea of how you can reproduce it.

    Hope you come up with a solution

    thank you

    Thursday, January 10, 2013 9:59 AM
  • Hi ,

    Any news ?

    Monday, January 14, 2013 7:46 AM
  • Hi, I'm having the same problem on my surface tablet.
    Monday, January 21, 2013 7:54 AM
  • It is only happening in the tablet and not in the Simulator.

    I think either it's a "tablet" bug or Metro UI Bug.

    Can anyone help on this ?

    thank you

    Wednesday, January 23, 2013 6:35 AM
  • Thanks for the bug reports everyone. We'll have this fixed in the next minor update.
    • Proposed as answer by Ionel Lescai Thursday, January 31, 2013 1:26 PM
    Wednesday, January 23, 2013 4:19 PM
  • Hi ,

    After the update I've just downloaded this one is fixed.

    Everything is OK now.

    thanks Microsoft

    • Marked as answer by zakkar Friday, February 8, 2013 10:31 AM
    Friday, February 8, 2013 10:31 AM