コード例 #1
0
        private async static Task<bool> ShowMapWithOptionsAsyncInternal(MapOptions options)
        {
            if (options == null)
            {
                return await ShowMapAsync();
            }

            return await LaunchMapApp(OptionsToString(options));
        }
コード例 #2
0
        private async static Task <bool> ShowMapWithOptionsAsyncInternal(MapOptions options)
        {
            if (options == null)
            {
                return(await ShowMapAsync());
            }

            return(await LaunchMapApp(OptionsToString(options)));
        }
コード例 #3
0
        public async void ButtonSearchRouteTapped(object sender, TappedRoutedEventArgs e)
        {
            var options = new MapOptions
            {
                ShowTraffic = true,
                ViewStyle = MapViewStyle.Aerial
            };

            await MapsHelper.SearchDirectionsAsync(new MapAddress("Montreal"), new MapAddress("Ottawa"), options);
        }
コード例 #4
0
        public async void ButtonMapOptionsTapped(object sender, TappedRoutedEventArgs e)
        {
            var options = new MapOptions
            {
                ZoomLevel = new MapZoomLevel(16),
                ShowTraffic = true,
                CenterPoint = new MapPosition(43.649126, -79.377885)
            };

            await WindowsMapsHelper.MapsHelper.ShowMapWithOptionsAsync(options);
        }
コード例 #5
0
        private async static Task<bool> SearchDirectionsAsyncInternal(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
        {
            var startPointStr = startPoint == null ? String.Empty : startPoint.ToString();
            var endPointStr = endPoint == null ? String.Empty : endPoint.ToString();

            var sb = new StringBuilder();

            if (options != null)
            {
                sb.Append(OptionsToString(options));
            }

            if (!String.IsNullOrWhiteSpace(startPointStr) || !String.IsNullOrWhiteSpace(endPointStr))
            {
                sb.AppendFormat("&rtp={0}~{1}", startPointStr, endPointStr);
            }

            return await LaunchMapApp(sb.ToString());
        }
コード例 #6
0
        private async static Task<bool> SearchAsyncInternal(string termToSearch, string whereToSearch, MapOptions options)
        {
            var sb = new StringBuilder();

            if (options != null)
            {
                sb.Append(OptionsToString(options));
            }

            if (!String.IsNullOrWhiteSpace(termToSearch))
            {
                sb.AppendFormat("&q={0}", termToSearch);
            }

            if (!String.IsNullOrWhiteSpace(whereToSearch))
            {
                sb.AppendFormat("&where={0}", whereToSearch);
            }

            return await LaunchMapApp(sb.ToString());
        }
コード例 #7
0
        private static string OptionsToString(MapOptions options)
        {
            var sb = new StringBuilder();

            if (options.CenterPoint != null)
            {
                sb.AppendFormat("cp={0}", options.CenterPoint.ToPointString());
            }

            if (options.ZoomLevel != null)
            {
                sb.AppendFormat("&lvl={0:0.00}", options.ZoomLevel.ZoomLevel);
            }

            if (options.BoundingBox != null &&
                options.BoundingBox.LowerLeftCorner != null &&
                options.BoundingBox.UpperRightCorner != null)
            {
                sb.AppendFormat("&bb={0}_{1}~{2}_{3}",
                                options.BoundingBox.LowerLeftCorner.Latitude,
                                options.BoundingBox.LowerLeftCorner.Longitude,
                                options.BoundingBox.UpperRightCorner.Latitude,
                                options.BoundingBox.UpperRightCorner.Longitude);
            }

            if (options.ViewStyle != MapViewStyle.Default)
            {
                sb.AppendFormat("&sty={0}", options.ViewStyle == MapViewStyle.Aerial ? "a" : "r");
            }

            if (options.ShowTraffic)
            {
                sb.Append("&trfc=1");
            }

            return(sb.ToString().TrimStart(new[] { '&' }));
        }
コード例 #8
0
 /// <summary>
 /// Searches driving directions for provided points
 /// </summary>
 public static IAsyncOperation<bool> SearchDirectionsAsync(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
 {
     return AsyncInfo.Run(token => SearchDirectionsAsyncInternal(startPoint, endPoint, options));
 }
コード例 #9
0
 /// <summary>
 /// Searches provided term in desired area
 /// </summary>
 public static IAsyncOperation <bool> SearchAsync(string termToSearch, string whereToSearch, MapOptions options)
 {
     return(AsyncInfo.Run(token => SearchAsyncInternal(termToSearch, whereToSearch, options)));
 }
コード例 #10
0
 /// <summary>
 /// Searches provided term in desired area
 /// </summary>
 public static IAsyncOperation<bool> SearchAsync(string termToSearch, string whereToSearch, MapOptions options)
 {
     return AsyncInfo.Run(token => SearchAsyncInternal(termToSearch, whereToSearch, options));
 }
コード例 #11
0
        private static string OptionsToString(MapOptions options)
        { 
            var sb = new StringBuilder();
            
            if (options.CenterPoint != null)
            {
                sb.AppendFormat("cp={0}", options.CenterPoint.ToPointString());
            }

            if (options.ZoomLevel != null)
            {
                sb.AppendFormat("&lvl={0:0.00}", options.ZoomLevel.ZoomLevel);
            }

            if (options.BoundingBox != null && 
                options.BoundingBox.LowerLeftCorner!= null && 
                options.BoundingBox.UpperRightCorner!= null)
            {
                sb.AppendFormat("&bb={0}_{1}~{2}_{3}", 
                                options.BoundingBox.LowerLeftCorner.Latitude, 
                                options.BoundingBox.LowerLeftCorner.Longitude,
                                options.BoundingBox.UpperRightCorner.Latitude, 
                                options.BoundingBox.UpperRightCorner.Longitude);
            }

            if (options.ViewStyle != MapViewStyle.Default)
            {
                sb.AppendFormat("&sty={0}", options.ViewStyle == MapViewStyle.Aerial ? "a" : "r");
            }

            if (options.ShowTraffic)
            {
                sb.Append("&trfc=1");
            }            

            return sb.ToString().TrimStart(new[]{'&'});
        }
コード例 #12
0
 /// <summary>
 /// Shows map configured according to the provided options
 /// </summary>
 public static IAsyncOperation<bool> ShowMapWithOptionsAsync(MapOptions options)
 {
     return AsyncInfo.Run(token => ShowMapWithOptionsAsyncInternal(options));
 }
コード例 #13
0
        public void ShowMap()
        {
            // TODO: Show a pin or something with current air quality measurements? (nice to have, seems not possible right now)
            var options = new MapOptions()
                              {
                                  CenterPoint =
                                      new MapPosition(SelectedMeasurement.Location.Latitude,
                                                      SelectedMeasurement.Location.Longitude)
                              };

            MapsHelper.ShowMapWithOptionsAsync(options);
        }
コード例 #14
0
 /// <summary>
 /// Shows map configured according to the provided options
 /// </summary>
 public static IAsyncOperation <bool> ShowMapWithOptionsAsync(MapOptions options)
 {
     return(AsyncInfo.Run(token => ShowMapWithOptionsAsyncInternal(options)));
 }
コード例 #15
0
        private async static Task <bool> SearchAsyncInternal(string termToSearch, string whereToSearch, MapOptions options)
        {
            var sb = new StringBuilder();

            if (options != null)
            {
                sb.Append(OptionsToString(options));
            }

            if (!String.IsNullOrWhiteSpace(termToSearch))
            {
                sb.AppendFormat("&q={0}", termToSearch);
            }

            if (!String.IsNullOrWhiteSpace(whereToSearch))
            {
                sb.AppendFormat("&where={0}", whereToSearch);
            }

            return(await LaunchMapApp(sb.ToString()));
        }
コード例 #16
0
        private async static Task <bool> SearchDirectionsAsyncInternal(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
        {
            var startPointStr = startPoint == null ? String.Empty : startPoint.ToString();
            var endPointStr   = endPoint == null ? String.Empty : endPoint.ToString();

            var sb = new StringBuilder();

            if (options != null)
            {
                sb.Append(OptionsToString(options));
            }

            if (!String.IsNullOrWhiteSpace(startPointStr) || !String.IsNullOrWhiteSpace(endPointStr))
            {
                sb.AppendFormat("&rtp={0}~{1}", startPointStr, endPointStr);
            }

            return(await LaunchMapApp(sb.ToString()));
        }
コード例 #17
0
 /// <summary>
 /// Searches driving directions for provided points
 /// </summary>
 public static IAsyncOperation <bool> SearchDirectionsAsync(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
 {
     return(AsyncInfo.Run(token => SearchDirectionsAsyncInternal(startPoint, endPoint, options)));
 }