none
Bing map(windows 8) not covering all pushpins on center view RRS feed

  • Question

  • Hi All,

    I am using following code to place all my pushpins so that it can directly visible to the user instead of scrolling.. but the issue is top left and top right pushpins are half visible.. Am I missing anything ? any suggestions?

    foreach (Model.Location location in mapLocations)
                        {
                            Bing.Maps.Location binglocation = new Location(location.Latitude,location.Longitude);

                            Pushpin pushpin = new Pushpin();
                            pushpin.Tapped += pushpin_Tapped;
                            MapLayer.SetPosition(pushpin, binglocation);
                            myMap.Children.Add(pushpin);

                            locationCollection.Add(binglocation);

                        }
                        var locationRect = new LocationRect(locationCollection);
                        try
                        {
                            locationRect.Height = locationRect.Height ;
                            locationRect.Width = locationRect.Width ;
                        }
                        catch
                        {
                        }
                        myMap.SetView(locationRect);

    here is my xaml code:

       <bingMap:Map  Credentials="my key" Width="670"  x:Name="myMap">
    <bingMap:MapItemsControl >
                </bingMap:MapItemsControl >
            </bingMap:Map>

     
    Sunday, June 30, 2013 10:06 PM

Answers

  • The reason for this is that the location rect is based on the coordinates and does not take into consideration the size of the pushpins themselves (understandable since you are only passing in an array of coordinates). What you can do is buffer the location rect. I've actually been working on coming up with a nice solution for buffering the location rect and am currently finding this works well:

    //Buffer around bounding box to ensure pushpins appear in view
    int bufferPx = 45;
    
    double zoom = Math.Log((360 * (MyMap.ActualWidth - (2 * bufferPx))) / (256 * locationRect.Width)) / Math.Log(2);
    I then use the center value from the locationRect and the calculated zoom value to set the map view.


    http://rbrundritt.wordpress.com

    Monday, July 1, 2013 12:34 PM
  • The buffer size is a measurement in pixels. You decide how much of a buffer you want to use. I would recommend with using the height of your pushpin in pixels as the buffer.

    http://rbrundritt.wordpress.com

    Thursday, March 27, 2014 10:56 AM

All replies

  • The reason for this is that the location rect is based on the coordinates and does not take into consideration the size of the pushpins themselves (understandable since you are only passing in an array of coordinates). What you can do is buffer the location rect. I've actually been working on coming up with a nice solution for buffering the location rect and am currently finding this works well:

    //Buffer around bounding box to ensure pushpins appear in view
    int bufferPx = 45;
    
    double zoom = Math.Log((360 * (MyMap.ActualWidth - (2 * bufferPx))) / (256 * locationRect.Width)) / Math.Log(2);
    I then use the center value from the locationRect and the calculated zoom value to set the map view.


    http://rbrundritt.wordpress.com

    Monday, July 1, 2013 12:34 PM
  • But , how to calculate Buffer size?
    Thursday, March 27, 2014 7:09 AM
  • The buffer size is a measurement in pixels. You decide how much of a buffer you want to use. I would recommend with using the height of your pushpin in pixels as the buffer.

    http://rbrundritt.wordpress.com

    Thursday, March 27, 2014 10:56 AM