Esempio n. 1
0
        private void SetUpMap()
        {
            GraphicsLayer layer =
                AssociatedObject.Layers.FirstOrDefault(l => !String.IsNullOrWhiteSpace(l.ID) && l.ID.Equals(ID)) as GraphicsLayer;

            if (ItemsSource != null && Symbol != null && !String.IsNullOrWhiteSpace(ID))
            {
                if (layer != null)
                {
                    AssociatedObject.Layers.Remove(layer);
                }
                layer = new GraphicsLayer();
                layer.MouseLeftButtonDown += layer_MouseLeftButtonDown;
                layer.Renderer             = new SimpleRenderer()
                {
                    Symbol = Symbol
                };

                PointDataSource pds = new PointDataSource();
                pds.XCoordinateBinding   = new Binding(XPropertyPath);
                pds.YCoordinateBinding   = new Binding(YPropertyPath);
                pds.IsSelectedBinding    = new Binding(SelectedPropertyPath);
                pds.ItemsSource          = ItemsSource;
                pds.DataSpatialReference = new SpatialReference(Esri.GCS_WGS_1984);
                layer.GraphicsSource     = pds;
                layer.ID = ID;
                AssociatedObject.Layers.Add(layer);
            }
            else if (layer != null)
            {
                AssociatedObject.Layers.Remove(layer);
            }
        }
Esempio n. 2
0
        private void UpdatePointData(Point data)
        {
            if (PointDataSource == null)
            {
                PointDataSource = new ObservableDataSource <Point>();
            }
            //this.pointdatasource.appendasync(base.dispatcher, data);
            if (PointDataSource.Collection.Count > 60)
            {
                PointDataSource.Collection.RemoveAt(0);
                PointDataSource.ResumeUpdate();
            }
            this.PointDataSource.AppendMany(new List <Point>()
            {
                data
            });

            //int index = (int)(data.X % 10);
            //animatedY[index] = data.Y+1.8;
            //animatedDataSource.RaiseDataChanged();
        }
        private void Init()
        {
            try
            {
                var bitmapLayer = AssociatedObject.Layers.FirstOrDefault(l => !String.IsNullOrWhiteSpace(l.ID) && l.ID.Equals(BitmapLayerId)) as GraphicsLayer;

                if (!String.IsNullOrWhiteSpace(BitmapLayerId))
                {
                    if (bitmapLayer != null)
                    {
                        AssociatedObject.Layers.Remove(bitmapLayer);
                    }
                    bitmapLayer = new GraphicsLayer {
                        ID = BitmapLayerId
                    };
                    var graphic = new Graphic {
                        Symbol = new ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol()
                    };


                    bitmapLayer.Graphics.Add(graphic);

                    AssociatedObject.Layers.Add(bitmapLayer);
                }


                _data       = new ObservableCollection <object>();
                _dataSource = new PointDataSource
                {
                    XCoordinateBinding = new Binding(XPropertyPath),
                    YCoordinateBinding = new Binding(YPropertyPath),

                    ItemsSource          = _data,
                    DataSpatialReference = new SpatialReference(Esri.GCS_WGS_1984)
                };

                var layer = AssociatedObject.Layers.FirstOrDefault(l => !String.IsNullOrWhiteSpace(l.ID) && l.ID.Equals(ItemLayerId)) as GraphicsLayer;

                if (Symbol != null && !String.IsNullOrWhiteSpace(ItemLayerId))
                {
                    if (layer != null)
                    {
                        AssociatedObject.Layers.Remove(layer);
                    }
                    layer = new GraphicsLayer
                    {
                        Renderer = new SimpleRenderer {
                            Symbol = Symbol
                        },
                        GraphicsSource = _dataSource,
                        ID             = ItemLayerId
                    };

                    AssociatedObject.Layers.Add(layer);
                }
                else if (layer != null)
                {
                    AssociatedObject.Layers.Remove(layer);
                }
            }
            catch (Exception exception)
            {
            }
            AssociatedObject.MouseDown += AssociatedObject_MouseDown;
            GraphicsLayer graphicsLayer = AssociatedObject.Layers["Entities"] as GraphicsLayer;

            graphicsLayer.MouseLeftButtonDown  += graphicsLayer_MouseLeftButtonDown;
            graphicsLayer.MouseRightButtonDown += graphicsLayer_MouseRightButtonDown;
        }