Esempio n. 1
0
        /// <summary> Makes the geocoding result visible on the map. The map display section is adapted to the map
        /// rectangle containing all results. </summary>
        /// <param name="sender"> The geocoder instance which is providing results. </param>
        private void SetMapEnvelopeToResult(GeocoderBase sender)
        {
            #region doc:bring result into view
            if (Dispatcher.FromThread(Thread.CurrentThread) != null)
            {
                sender.ContentLayer.Refresh();

                var resultList = sender.Addresses;

                if (resultList.Count > 1)
                {
                    var winPoints = from address in resultList
                                    select GeoTransform.PtvMercatorToWGS(new Point(address.coordinates.point.x, address.coordinates.point.y));

                    _wpfMap.SetEnvelope(new MapRectangle(winPoints).Inflate(1.2));
                }
                else if (resultList.Count == 1)
                {
                    _wpfMap.SetMapLocation(GeoTransform.PtvMercatorToWGS(new Point(
                                                                             resultList[0].coordinates.point.x,
                                                                             resultList[0].coordinates.point.y)), _wpfMap.Zoom);
                }

                Mouse.OverrideCursor = null;
            }
            else
            {
                Application.Current.Dispatcher.BeginInvoke(new Action <GeocoderBase>(SetMapEnvelopeToResult), sender);
            }
            #endregion
        }
Esempio n. 2
0
        /// <summary>Sets the map view to the extend of the route. </summary>
        /// <param name="route"> The route object which should be centered in the map view. </param>
        private void ZoomToRoute(Route route)
        {
            var winPoints = from plainPoint in route.polygon.lineString.wrappedPoints
                            select new System.Windows.Point(plainPoint.x, plainPoint.y);

            _wpfMap.SetEnvelope(new MapRectangle(winPoints).Inflate(1.2), "PTV_MERCATOR");
        }