Bing Map control on WPF window - How to make map size so that all pushpins display? RRS feed

  • Question

  • I have a WPF form where several pushpins will display as I read customer data from my database.  But I want the map to automatically resize so that all pushpins fit on the map.  Is this possible?
    Monday, February 11, 2013 8:32 PM


All replies

  • Yes. Pass a list of the coordinates into the LocationRect class: and then use this to set the map view:

    Tuesday, February 12, 2013 10:33 AM
  • Thanks for the reply Richard.  I can't seem to find any examples though.  I'm brand new to WPF and Bing Maps.  Not sure I understand the various overloads for LocationRect.  I get various lat and long coordinates as I read thru my customer table and plot pushpins.  But I'm not sure how to apply this to the LocationRect class.  Does anyone have an example of this?
    Tuesday, February 12, 2013 12:32 PM
  • First loop through your data and create a List of Location objects:

    List<Location> data = new List<Location>();

    //Loop through your data and do this:

    data.add(new Location(yourData.Latitidue, yourData.Longitude));

    Then use this to create a LocationRect object:

    LocationRect boundingBox = new LocationRect(data);

    Finally use this to set the map view:


    Tuesday, February 12, 2013 1:35 PM