Пример #1
0
 private void UpdateMap(string polyline)
 {
     if (!String.IsNullOrEmpty(polyline))
     {
         List <BasicGeoposition> Coordinates = PolylineDecoder.Decode(polyline);
         MapPolyline             MapPolyline = new MapPolyline();
         MapPolyline.StrokeColor     = Colors.OrangeRed;
         MapPolyline.StrokeThickness = 2;
         MapPolyline.Path            = new Geopath(Coordinates);
         this.FeedMapView.MapElements.Add(MapPolyline);
         FeedMapView.Center = new Geopoint(Coordinates[0]);
     }
 }
Пример #2
0
        public static async Task <Image> LoadActivityPreviewAsync(string polyline, Dimension dimension, MapType mapType)
        {
            if (dimension.Width == 0 || dimension.Height == 0)
            {
                throw new ArgumentException("Both width and height must be greater than zero.");
            }
            List <Coordinate> c           = PolylineDecoder.Decode(polyline);
            string            markerStart = $"&markers=icon:http://tinyurl.com/np8ozqm%7C{c.First().Latitude},{c.First().Longitude}";
            string            markerEnd   = $"&markers=icon:http://tinyurl.com/mzj8mvq%7C{c.Last().Latitude},{c.Last().Longitude}";
            string            url         = $"http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype={mapType.ToString().ToLower()}&size={dimension.Width}x{dimension.Height}&{markerStart}&{markerEnd}&path=weight:3|color:red|enc:{polyline}";

            return(await ImageLoader.LoadImage(new Uri(url)));
        }
Пример #3
0
        /// <summary>
        /// Loads an image of a map.
        /// </summary>
        /// <param name="polyline">The polyline of your activity.</param>
        /// <param name="dimension">The dimension of the picture which will be returned.</param>
        /// <param name="mapType">Choose the map type of the image.</param>
        /// <returns>An image of your activity on the specified map.</returns>
        public static async Task <Image> LoadActivityPreviewAsync(String polyline, Dimension dimension, MapType mapType)
        {
            if (dimension.Width == 0 || dimension.Height == 0)
            {
                throw new ArgumentException("Both width and height must be greater than zero.");
            }

            List <Coordinate> c           = PolylineDecoder.Decode(polyline);
            String            markerStart = String.Format("&markers=icon:http://tinyurl.com/np8ozqm%7C{0},{1}", c.First().Latitude, c.First().Longitude);
            String            markerEnd   = String.Format("&markers=icon:http://tinyurl.com/mzj8mvq%7C{0},{1}", c.Last().Latitude, c.Last().Longitude);

            String url = String.Format("http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype={0}&size={1}x{2}&{3}&{4}&path=weight:3|color:red|enc:{5}",
                                       mapType.ToString().ToLower(),
                                       dimension.Width,
                                       dimension.Height,
                                       markerStart,
                                       markerEnd,
                                       polyline);

            Image image = await ImageLoader.LoadImage(new Uri(url));

            return(image);
        }