Beispiel #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
        }
Beispiel #2
0
        /// <summary>
        /// Handler for clicking an item in the waypoint list of the route context menu. This handler
        /// sets the map center to the clicked item.
        /// </summary>
        /// <param name="sender"> The sender of the Click event. </param>
        /// <param name="e"> The event parameters. </param>
        private void WaypointClicked(object sender, RoutedEventArgs e)
        {
            int firstWaypointItemIndex = GetIndexOfLastStaticContextMenuItem() + 2;
            int wayPointIndex          = cm.Items.IndexOf(sender) - firstWaypointItemIndex;

            var point = wayPoints[wayPointIndex];

            _wpfMap.SetMapLocation(new System.Windows.Point(point.x, point.y),
                                   _wpfMap.Zoom, "PTV_MERCATOR");
        }