private void mapView_Loaded(object sender, RoutedEventArgs e) { mapView.MapUnit = GeographyUnit.Meter; mapView.ZoomLevelSet = new ThinkGeoCloudMapsZoomLevelSet(); // Please input your ThinkGeo Cloud Client ID / Client Secret to enable the background map. // Create background world map with vector tile requested from ThinkGeo Cloud Service. ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay(SampleHelper.ThinkGeoCloudId, SampleHelper.ThinkGeoCloudSecret, ThinkGeoCloudVectorMapsMapType.Light); mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay); //Add LayerOverlay to map. LayerOverlay noaaWeatherStationOverlay = new LayerOverlay(); mapView.Overlays.Add(noaaWeatherStationOverlay); //Add NoaaWeatherStationFeatureLayer to LayerOverlay. NoaaWeatherStationFeatureLayer noaaWeatherStationFeatureLayer = new NoaaWeatherStationFeatureLayer(); noaaWeatherStationFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new NoaaWeatherStationStyle()); noaaWeatherStationFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; noaaWeatherStationFeatureLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(4326, 3857); noaaWeatherStationOverlay.Layers.Add(noaaWeatherStationFeatureLayer); //move map to usa. mapView.CurrentExtent = new RectangleShape(-14534042, 9147820, -4906645, 1270446); mapView.Refresh(); }
/// <summary> /// Setup the map with the ThinkGeo Cloud Maps overlay. Also, add the NOAA Weather Station layer to the map /// </summary> protected override void OnAppearing() { base.OnAppearing(); // It is important to set the map unit first to either feet, meters or decimal degrees. mapView.MapUnit = GeographyUnit.Meter; // Create background world map with vector tile requested from 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); // Create a new overlay that will hold our new layer and add it to the map. LayerOverlay weatherOverlay = new LayerOverlay(); mapView.Overlays.Add("Weather", weatherOverlay); // Create the new layer and set the projection as the data is in srid 4326 and our background is srid 3857 (spherical mercator). NoaaWeatherStationFeatureLayer nOAAWeatherStationLayer = new NoaaWeatherStationFeatureLayer(); nOAAWeatherStationLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(4326, 3857); // Add the new layer to the overlay we created earlier weatherOverlay.Layers.Add("Noaa Weather Stations", nOAAWeatherStationLayer); // Get the layers feature source and setup an event that will refresh the map when the data refreshes var featureSource = (NoaaWeatherStationFeatureSource)nOAAWeatherStationLayer.FeatureSource; loadingIndicator.IsRunning = true; loadingLayout.IsVisible = true; featureSource.StationsUpdated -= FeatureSource_StationsUpdated; featureSource.StationsUpdated += FeatureSource_StationsUpdated; // Create the weather stations style and add it on zoom level 1 and then apply it to all zoom levels up to 20. nOAAWeatherStationLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new NoaaWeatherStationStyle()); nOAAWeatherStationLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; // Set the extent to a view of the US mapView.CurrentExtent = new RectangleShape(-14927495.374917, 8262593.0543992, -6686622.84891633, 1827556.23117885); // Refresh the map. mapView.Refresh(); }
protected override Collection <Layer> GetLayersCore(GetLayersParameters getLayersParameters) { NoaaWeatherStationFeatureLayer noaaWeatherStationFeatureLayer = new NoaaWeatherStationFeatureLayer(); GisEditor.LayerManager.FeatureIdColumnNames[noaaWeatherStationFeatureLayer.FeatureSource.Id] = "StationId"; CompositeStyle compositeStyle = new CompositeStyle(new NoaaWeatherStationStyle()); foreach (ZoomLevel zoomLevel in GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels()) { ZoomLevel newZoomLevel = new ZoomLevel(zoomLevel.Scale); newZoomLevel.CustomStyles.Add(compositeStyle); noaaWeatherStationFeatureLayer.ZoomLevelSet.CustomZoomLevels.Add(newZoomLevel); } return(new Collection <Layer> { noaaWeatherStationFeatureLayer }); }
private void Form_Load(object sender, EventArgs e) { //// It is important to set the map unit first to either feet, meters or decimal degrees. mapView.MapUnit = GeographyUnit.Meter; // Create background world map with vector tile requested from ThinkGeo Cloud Service. ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light); mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay); // Create a new overlay that will hold our new layer and add it to the map. LayerOverlay weatherOverlay = new LayerOverlay(); mapView.Overlays.Add("Weather", weatherOverlay); // Create the new layer and set the projection as the data is in srid 4326 and our background is srid 3857 (spherical mercator). NoaaWeatherStationFeatureLayer nOAAWeatherStationLayer = new NoaaWeatherStationFeatureLayer(); nOAAWeatherStationLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(4326, 3857); // Add the new layer to the overlay we created earlier weatherOverlay.Layers.Add(nOAAWeatherStationLayer); // Get the layers feature source and setup an event that will refresh the map when the data refreshes var featureSource = (NoaaWeatherStationFeatureSource)nOAAWeatherStationLayer.FeatureSource; featureSource.StationsUpdated -= FeatureSource_StationsUpdated; featureSource.StationsUpdated += FeatureSource_StationsUpdated; // Create the weather stations style and add it on zoom level 1 and then apply it to all zoom levels up to 20. nOAAWeatherStationLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new NoaaWeatherStationStyle()); nOAAWeatherStationLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; // Set the extent to a view of the US mapView.CurrentExtent = new RectangleShape(-14927495.374917, 8262593.0543992, -6686622.84891633, 1827556.23117885); // Refresh the map. mapView.Refresh(); }