none
zoom to pushpins/geometry RRS feed

  • Question

  • I load a KML file into my app with 80 or so pushpins. I then create a new geometry from the KML with only 2 pushpins. I would like the app to zoom into the 2 pushpins so that they are at the extremes of the display, I would also like to rotate the map so that the pins are displayed at the top and bottom of the display. Could someone please point me the direction I should be looking at. I'm not sure how I translate required zoom to a geometry to a display... if that makes sense.

    many thanks.

    Wednesday, September 17, 2014 8:52 PM

Answers

  • ok so I managed to do this pretty simply actually, using the really excellent Microsoft.Maps.SpatialToolbox.

     Dim geomdata As New SpatialDataSet()
                            Dim geoms = New List(Of Geometry)()

                            'try and load the first data set
                            Debug.WriteLine("H01")
                            For Each geom In data.Geometries
                                If geom.Metadata.Title.Contains("H01") Then
                                    System.Diagnostics.Debug.WriteLine("H1")
                                    geoms.Add(geom)
                                Else
                                    Debug.WriteLine("not H1")
                                End If
                            Next

                            geomdata.Geometries = geoms
                            geomdata.BoundingBox = geoms.Envelope()

    • Marked as answer by I_windows Thursday, September 18, 2014 8:09 AM
    Thursday, September 18, 2014 8:09 AM

All replies

  • ok so I managed to do this pretty simply actually, using the really excellent Microsoft.Maps.SpatialToolbox.

     Dim geomdata As New SpatialDataSet()
                            Dim geoms = New List(Of Geometry)()

                            'try and load the first data set
                            Debug.WriteLine("H01")
                            For Each geom In data.Geometries
                                If geom.Metadata.Title.Contains("H01") Then
                                    System.Diagnostics.Debug.WriteLine("H1")
                                    geoms.Add(geom)
                                Else
                                    Debug.WriteLine("not H1")
                                End If
                            Next

                            geomdata.Geometries = geoms
                            geomdata.BoundingBox = geoms.Envelope()

    • Marked as answer by I_windows Thursday, September 18, 2014 8:09 AM
    Thursday, September 18, 2014 8:09 AM
  • For those who might not be using the Microsoft.Maps.SpatialToolbox library this can also be done by taking the coordinates of the two pushpins and passing them to the LocationRect class as a LocationCollection: http://msdn.microsoft.com/en-us/library/hh846491.aspx This will generate a bounding box. From there you just need to use the SetView method on the map.

    http://rbrundritt.wordpress.com

    Thursday, September 18, 2014 8:28 AM