private async Task <Graphic> GraphicForPoint(MapPoint point) { #if WINDOWS_UWP // Get current assembly that contains the image Assembly currentAssembly = GetType().GetTypeInfo().Assembly; #else // Get current assembly that contains the image Assembly currentAssembly = Assembly.GetExecutingAssembly(); #endif // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( "ArcGISRuntime.Resources.PictureMarkerSymbols.pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 60; pinSymbol.Height = 60; // The image is a pin; offset the image so that the pinpoint // is on the point rather than the image's true center pinSymbol.LeaderOffsetX = 30; pinSymbol.OffsetY = 14; return(new Graphic(point, pinSymbol)); }
private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) { // Get current assembly that contains the image Assembly currentAssembly = GetType().GetTypeInfo().Assembly; // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( "ArcGISRuntime.Resources.PictureMarkerSymbols.pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 50; pinSymbol.Height = 50; // Create location for the pint MapPoint pinPoint = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(pinGraphic); }
private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) { Assembly currentAssembly = null; #if WINDOWS_UWP // Get current assembly that contains the image currentAssembly = GetType().GetTypeInfo().Assembly; #else // Get current assembly that contains the image currentAssembly = Assembly.GetExecutingAssembly(); #endif var imgsource = currentAssembly.GetManifestResourceNames(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy var resourceStream = currentAssembly.GetManifestResourceStream(imgsource[1]);// "pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Height = 50; pinSymbol.Width = 50; // Create location for the pint MapPoint pinPoint = new MapPoint(8574997.37890646, 3326933.37199782, SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(pinGraphic); }
private async Task EnsureLoaded() { await Locator.LoadAsync(); Stream?resourceStream = Assembly.GetAssembly(typeof(LocatorSearchSource))?.GetManifestResourceStream( "Esri.ArcGISRuntime.Toolkit.EmbeddedResources.pin_red.png"); if (resourceStream != null) { PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 33; pinSymbol.Height = 33; pinSymbol.LeaderOffsetX = 16.5; pinSymbol.OffsetY = 16.5; DefaultSymbol = pinSymbol; } if (DisplayName != Locator?.LocatorInfo?.Name && !string.IsNullOrWhiteSpace(Locator?.LocatorInfo?.Name)) { DisplayName = Locator?.LocatorInfo?.Name ?? "Locator"; } GeocodeParameters.ResultAttributeNames.Add("*"); }
public async Task CreatePictureMarker(GraphicsOverlay overlay, Uri _uri) { overlay.Graphics.Clear(); var resourceStream = GetStreamFromUrl(_uri.ToString()); MainViewModel.SelectedPlace_Bitmap = CreateBitMap_FromUri(_uri); PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = MainViewModel.MyWindow.GridMap.ActualWidth; pinSymbol.Height = MainViewModel.MyWindow.GridMap.ActualHeight; MapPoint pinPoint = MainViewModel.CenterPoint; Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); overlay.Graphics.Add(pinGraphic); overlay.Graphics[0].ZIndex = 2; overlay.Opacity = 0.5; }
public async void layerLoad(MapView myMapView) { overlay = new GraphicsOverlay(); myMapView.GraphicsOverlays.Add(overlay); Assembly currentAssembly = null; #if WINDOWS_UWP // Get current assembly that contains the image currentAssembly = GetType().GetTypeInfo().Assembly; #else // Get current assembly that contains the image currentAssembly = Assembly.GetExecutingAssembly(); #endif // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy var beerMug = currentAssembly.GetManifestResourceStream("ArcGISApp.images.beer_mug.png"); PictureMarkerSymbol beer = await PictureMarkerSymbol.CreateAsync(beerMug); ArcGISApp.JSONLoader loader = new ArcGISApp.JSONLoader(); if (loader.bars.Count > 0) { MapPoint mp; Graphic graphic; foreach (Bar b in loader.bars) { mp = b.getMapPoint(); graphic = new Graphic(mp, beer); Dictionary <string, object> dict = b.getAttributes(); foreach (KeyValuePair <string, object> obj in dict) { graphic.Attributes.Add(obj); } overlay.Graphics.Add(graphic); } } }
private async Task <PictureMarkerSymbol> GetPictureMarker() { // Get current assembly that contains the image Assembly currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( "ArcGISRuntime.Resources.PictureMarkerSymbols.pin_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 50; pinSymbol.Height = 50; pinSymbol.LeaderOffsetX = 30; pinSymbol.OffsetY = 14; return(pinSymbol); }
/// <summary> /// Creates and returns a Graphic associated with the given MapPoint /// </summary> private async Task<Graphic> GraphicForPoint(MapPoint point) { // Get current assembly that contains the image var currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy var resourceStream = currentAssembly.GetManifestResourceStream( "ArcGISRuntime.WPF.Resources.PictureMarkerSymbols.pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 60; pinSymbol.Height = 60; // The symbol is a pin; centering it on the point is incorrect. // The values below center the pin and offset it so that the pinpoint is accurate pinSymbol.LeaderOffsetX = 30; pinSymbol.OffsetY = 14; return new Graphic(point, pinSymbol); }
private async Task <PictureMarkerSymbol> GetVehiculeSymbol(Vehicule vehicule) { string symbolCacheKey = vehicule.Ligne + vehicule.Destination + vehicule.Cap; if (!_symbolsCache.ContainsKey(symbolCacheKey)) { VehiculeSymbol rawSymbol = await _symbolsManager.GetMapVehiculeSymbol(vehicule, _displayVehiculeDirection); PictureMarkerSymbol pictureMarkerSymbol = await PictureMarkerSymbol.CreateAsync(rawSymbol.Stream); pictureMarkerSymbol.Height = _config.Map.VehiculeSymbolHeight; pictureMarkerSymbol.Width = pictureMarkerSymbol.Height * (double)rawSymbol.Width / (double)rawSymbol.Height; pictureMarkerSymbol.OffsetY = (0.0 - rawSymbol.YOffsetFromCenter) * pictureMarkerSymbol.Height / (double)rawSymbol.Height; _symbolsCache.Add(symbolCacheKey, pictureMarkerSymbol); } PictureMarkerSymbol pictureMarkerSymbol2 = _symbolsCache[symbolCacheKey].Clone().As <PictureMarkerSymbol>(); pictureMarkerSymbol2.Opacity = _currentSymbolOpacity; return(pictureMarkerSymbol2); }
/// <summary> /// Creates and returns a Graphic associated with the given MapPoint /// </summary> private async Task <Graphic> GraphicForPoint(MapPoint point) { // Get current assembly that contains the image var currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy var resourceStream = currentAssembly.GetManifestResourceStream( "ArcGISRuntimeXamarin.Resources.PictureMarkerSymbols.pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 60; pinSymbol.Height = 60; // The image is a pin; offset the image so that the pinpoint // is on the point rather than the image's true center pinSymbol.OffsetX = pinSymbol.Width / 2; pinSymbol.OffsetY = pinSymbol.Height / 2; return(new Graphic(point, pinSymbol)); }
private async Task CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay) { // Create uri to the used image var symbolUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae"); // Create new symbol using asynchronous factory method from uri PictureMarkerSymbol campsiteSymbol = await PictureMarkerSymbol.CreateAsync(symbolUri); // Optionally set the size (if not set, the size in pixels of the image will be used) campsiteSymbol.Height = 18; campsiteSymbol.Width = 18; // Create location for the campsite MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(campsiteGraphic); }
//==========================放球站标记======================== private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) { // Get current assembly that contains the image Assembly currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( this.GetType(), "pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 50; pinSymbol.Height = 50; // Create location for the pint MapPoint pinPoint1 = new MapPoint(lon(111.35000), lat(30.73000), SpatialReferences.WebMercator); MapPoint pinPoint2 = new MapPoint(lon(114.05000), lat(30.60000), SpatialReferences.WebMercator); MapPoint pinPoint3 = new MapPoint(lon(112.78000), lat(28.010000), SpatialReferences.WebMercator); MapPoint pinPoint4 = new MapPoint(lon(115.00000), lat(25.87000), SpatialReferences.WebMercator); MapPoint pinPoint5 = new MapPoint(lon(115.90110), lat(28.59000), SpatialReferences.WebMercator); MapPoint pinPoint6 = new MapPoint(lon(116.97000), lat(30.62000), SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic pinGraphic1 = new Graphic(pinPoint1, pinSymbol); Graphic pinGraphic2 = new Graphic(pinPoint2, pinSymbol); Graphic pinGraphic3 = new Graphic(pinPoint3, pinSymbol); Graphic pinGraphic4 = new Graphic(pinPoint4, pinSymbol); Graphic pinGraphic5 = new Graphic(pinPoint5, pinSymbol); Graphic pinGraphic6 = new Graphic(pinPoint6, pinSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(pinGraphic1); overlay.Graphics.Add(pinGraphic2); overlay.Graphics.Add(pinGraphic3); overlay.Graphics.Add(pinGraphic4); overlay.Graphics.Add(pinGraphic5); overlay.Graphics.Add(pinGraphic6); }
//============地图展示 private async void Initialize() { LoadData(); //=====================放球站============= // Create overlay to where graphics are shown GraphicsOverlay overlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(overlay); try { await CreatePictureMarkerSymbolFromResources(overlay); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } //================== 二维场景探空仪展示 ============== //加载图片 int count = Global.DectorNamelist.Count; if (count > 0) { for (int i = 0; i < count; i++) { Assembly currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( this.GetType(), "qiqiu.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 35; pinSymbol.Height = 35; //位置 int index = 0; double positionOffset = 0.01 * index; MapPoint point = new MapPoint(111, 30, 0, SpatialReferences.Wgs84); // Create the graphic from the geometry and the symbol. Graphic _plane2D; _plane2D = new Graphic(point, pinSymbol); // Add the graphic to the overlay. overlay.Graphics.Add(_plane2D); Dector2D.Add(_plane2D); } } //==========================场景基础地图=========== // Create a new Scene with an imagery basemap Scene myScene = new Scene(Basemap.CreateImagery()); // Create a scene layer to show buildings in the Scene ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(new Uri(_buildingsServiceUrl)); myScene.OperationalLayers.Add(buildingsLayer); // Create an elevation(海拔) source for the Scene ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(new Uri(_elevationSourceUrl)); myScene.BaseSurface.ElevationSources.Add(elevationSrc); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); myScene.BaseSurface.ElevationSources.Add(elevationSource); // Add the Scene to the SceneView MySceneView.Scene = myScene; //======================三维探空仪==================== // Create the graphics overlay. GraphicsOverlay overlay1 = new GraphicsOverlay(); //=====放球站====== try { await CreatePictureMarkerSymbolFromResources(overlay1); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } MySceneView.GraphicsOverlays.Add(overlay1); if (Global.DectorNamelist.Count > 0) { for (int i = 0; i < Global.DectorNamelist.Count; i++) { GraphicsOverlay dectoroverlay = new GraphicsOverlay(); // Set the surface placement mode for the overlay. dectoroverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MapPoint point = new MapPoint(111, 30, 0, SpatialReferences.Wgs84); SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Blue, 20); Graphic _plane3D; // Create the graphic from the geometry and the symbol. _plane3D = new Graphic(point, circleSymbol); // Add the graphic to the overlay. dectoroverlay.Graphics.Add(_plane3D); // Show the graphics overlay in the scene. MySceneView.GraphicsOverlays.Add(dectoroverlay); Dector3D.Add(_plane3D); /* * * _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 30.0) * { * CameraPitchOffset = 75.0 * }; * MySceneView.CameraController = _orbitCameraController; */ } } //===========跟随相机控制======== //================加载探空仪位置信息=========== //==================动态更新=============== _animationTimer = new Timer(2000) { Enabled = true, AutoReset = true }; //动态更新探空仪位置 _animationTimer.Elapsed += AnimatePlane; //====二维预测轨迹===== //SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4); // _overlay.Renderer = new SimpleRenderer(lineSymbol); // MyMapView.GraphicsOverlays.Add(_overlay); //==========三维预测轨迹========= // SimpleLineSymbol lineSymbol1 = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4); // _overlay1.Renderer = new SimpleRenderer(lineSymbol1); // // Set the surface placement mode for the overlay. for (int i = 0; i < Global.DectorNamelist.Count; i++) { GraphicsOverlay _overlay1 = new GraphicsOverlay(); GraphicsOverlay _overlay = new GraphicsOverlay(); _overlay1.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; //MySceneView.GraphicsOverlays.Add(_overlay1); MySceneView.GraphicsOverlays.Add(_overlay1); MyMapView.GraphicsOverlays.Add(_overlay); Dector3Doverlay.Add(_overlay1); Dector2Doverlay.Add(_overlay); } //===================三维地图初始视点================ heading = 344.488; // Set the viewpoint with a new camera focused on the castle in Brest observerCamera = new Camera(new MapPoint(112, 29, 2495, SpatialReferences.Wgs84), heading, 74.1212, 0.0); await MySceneView.SetViewpointCameraAsync(observerCamera); //====================通过鼠标点击改变三维地图视点================== MyMapView.GeoViewTapped += Map_Tapped; if (Global.namelist.Count > 0) { string[] strArr = new string[3]; string sArguments = @"station.py"; //调用的python的文件名字 strArr[0] = Global.lonlist[0].ToString(); strArr[1] = Global.latlist[0].ToString(); strArr[2] = Global.radiuslist[0].ToString(); RunPythonScript(sArguments, "-u", strArr); } }