Exemplo n.º 1
0
        // 鹰眼
        private void myMapView_ViewpointChanged(object sender, EventArgs e)
        {
            // 声明鹰眼地图的覆盖层边框
            Esri.ArcGISRuntime.Geometry.Geometry eagleViewEnv = null;
            // 每次主地图的焦点改变, 都会清空鹰眼地图的覆盖层
            myMapView_Eagle.GraphicsOverlays.Clear();
            // 获取主地图的四至
            Esri.ArcGISRuntime.Geometry.Polygon vExtent = myMapView.VisibleArea;
            // 鹰眼地图的覆盖层边框等于主地图四至
            eagleViewEnv = vExtent.Extent;
            // 鹰眼地图的覆盖层边框为"红色"
            System.Drawing.Color lineColor = System.Drawing.Color.FromName("Red");
            // 鹰眼地图的覆盖层边框样式
            Esri.ArcGISRuntime.Symbology.SimpleLineSymbol lineSymbol = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol(Esri.ArcGISRuntime.Symbology.SimpleLineSymbolStyle.Dash, lineColor, 2.0);
            System.Drawing.Color fillColor = System.Drawing.Color.FromArgb(0, 255, 255, 255);
            Esri.ArcGISRuntime.Symbology.SimpleFillSymbol polySymbol = new Esri.ArcGISRuntime.Symbology.SimpleFillSymbol(Esri.ArcGISRuntime.Symbology.SimpleFillSymbolStyle.Solid, fillColor, lineSymbol);
            var graphicOverlay = new Esri.ArcGISRuntime.UI.GraphicsOverlay();
            // 几何图层
            var envGraphic = new Esri.ArcGISRuntime.UI.Graphic(eagleViewEnv, polySymbol);

            // 覆盖层
            graphicOverlay.Graphics.Add(envGraphic);
            // 覆盖层添加到鹰眼地图
            myMapView_Eagle.GraphicsOverlays.Add(graphicOverlay);
        }
        private async void LoadService(string uri)
        {
            var client = await StreamServiceClient.CreateAsync(new Uri(uri));

            client.FeatureTimeout = TimeSpan.FromMinutes(5); // Removes any features that hasn't reported back in over 5 minutes
            client.OnUpdate      += Client_OnUpdate;

            // Create overlay for rendering updates
            var si = typeof(LocationDisplay).Assembly.GetManifestResourceStream("Esri.ArcGISRuntime.Esri.ArcGISRuntime.LocationDisplayCourse.scale-200.png");
            var ri = await RuntimeImage.FromStreamAsync(si);

            PictureMarkerSymbol vehicleSymbol = new PictureMarkerSymbol(ri)
            {
                Width = 25, Height = 25
            };
            var overlay = new Esri.ArcGISRuntime.UI.GraphicsOverlay()
            {
                Renderer        = new SimpleRenderer(vehicleSymbol),
                SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) //In case we use it in 3D and have Z values
            };
            var headingField = client.ServiceInfo.Fields.Where(f => f.Name.ToLower() == "heading").Select(f => f.Name).FirstOrDefault();

            if (!string.IsNullOrEmpty(headingField))
            {
                overlay.Renderer.RotationExpression = $"[{headingField}]";
                overlay.Renderer.SceneProperties.HeadingExpression = $"[{headingField}]";
            }
            mapView.GraphicsOverlays.Add(overlay);
            client.Overlay = overlay;

            // Connect
            await client.ConnectAsync();
        }