/// <summary> /// Set up the map with the ThinkGeo Cloud Maps overlay and a feature layers for the shape to be queried and the returned elevation points /// </summary> protected override async void OnAppearing() { base.OnAppearing(); // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service. ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~", ThinkGeoCloudVectorMapsMapType.Light); thinkGeoCloudVectorMapsOverlay.VectorTileCache = new FileVectorTileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cache"), "CloudMapsVector"); mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay); // Set the map's unit of measurement to meters (Spherical Mercator) mapView.MapUnit = GeographyUnit.Meter; // Create a new InMemoryFeatureLayer to hold the shape drawn for the elevation query InMemoryFeatureLayer drawnShapeLayer = new InMemoryFeatureLayer(); // Create Point, Line, and Polygon styles to display the drawn shape, and apply them across all zoom levels drawnShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Star, 20, GeoBrushes.Blue); drawnShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(GeoPens.Blue); drawnShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(GeoPens.Blue, new GeoSolidBrush(new GeoColor(10, GeoColors.Blue))); drawnShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; // Create a new InMemoryFeatureLayer to display the elevation points returned from the query InMemoryFeatureLayer elevationPointsLayer = new InMemoryFeatureLayer(); // Create a point style for the elevation points elevationPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Star, 20, GeoBrushes.Blue); elevationPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; // Add the feature layers to an overlay, and add the overlay to the map LayerOverlay elevationFeaturesOverlay = new LayerOverlay(); elevationFeaturesOverlay.Layers.Add("Elevation Points Layer", elevationPointsLayer); elevationFeaturesOverlay.Layers.Add("Drawn Shape Layer", drawnShapeLayer); mapView.Overlays.Add("Elevation Features Overlay", elevationFeaturesOverlay); // Add an event to trigger the elevation query when a new shape is drawn mapView.TrackOverlay.TrackEnded += OnShapeDrawn; // Initialize the ElevationCloudClient with our ThinkGeo Cloud credentials elevationCloudClient = new ElevationCloudClient("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~"); // Create a sample line and get elevation along that line LineShape sampleShape = new LineShape("LINESTRING(-10776298.0601626 3912306.29684573,-10776496.3187036 3912399.45447343,-10776675.4679876 3912478.28015841,-10776890.4471285 3912516.49867234,-10777189.0292686 3912509.33270098,-10777329.9600387 3912442.4503016,-10777664.3720356 3912174.92070409)"); // Set the map extent to Frisco, TX mapView.CurrentExtent = sampleShape.GetBoundingBox(); await PerformElevationQuery(sampleShape); mapView.Refresh(); }
private static void GetAdjacentFeataureIds(FeatureSource featureSource, LineShape sourceShape, Collection <string> startIds, Collection <string> endIds) { Vertex startVertex = sourceShape.Vertices[0]; Vertex endVertex = sourceShape.Vertices[sourceShape.Vertices.Count - 1]; Collection <Feature> tempfeatures = featureSource.GetFeaturesInsideBoundingBox(sourceShape.GetBoundingBox(), ReturningColumnsType.NoColumns); foreach (Feature tempFeature in tempfeatures) { LineShape tempShape = ((MultilineShape)tempFeature.GetShape()).Lines[0]; if (sourceShape.Id == tempFeature.Id) { continue; } if (tempShape.Vertices.Contains(startVertex)) { startIds.Add(tempFeature.Id); } else if (tempShape.Vertices.Contains(endVertex)) { endIds.Add(tempFeature.Id); } } }