Пример #1
0
        private void drawPath(DateTime date)
        {
            Map1.MapElements.Clear();
            MapPolyline polygon = new MapPolyline();

            //polygon.StrokeColor = ;
            polygon.StrokeThickness = 3;
            polygon.Path            = new GeoCoordinateCollection();
            List <string> coordinates = App.read(App.getFileName(App.LOC_LOG, date));
            double        maxLat      = -90;
            double        maxLon      = -180;
            double        minLat      = 90;
            double        minLon      = 180;

            foreach (string coord in coordinates)
            {
                string[] line = coord.Split(new string[] { App.DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
                double   lat;
                double   lon;
                if (double.TryParse(line[1], out lat) && double.TryParse(line[2], out lon))
                {
                    maxLat = Math.Max(maxLat, lat);
                    maxLon = Math.Max(maxLon, lon);
                    minLat = Math.Min(minLat, lat);
                    minLon = Math.Min(minLon, lon);
                    polygon.Path.Add(new GeoCoordinate(lat, lon));
                }
            }
            if (polygon.Path.Count > 0)
            {
                // Map1.Center = new GeoCoordinate(minLat + ((maxLat - minLat) / 2), minLon, ((maxLon - minLon) / 2));
                Map1.MapElements.Add(polygon);
                //Map1.SetView(new LocationRectangle(maxLat, minLon, maxLat, maxLon));
                Map1.SetView(LocationRectangle.CreateBoundingRectangle(polygon.Path));
            }
        }