Exemplo n.º 1
0
        private static ILayer CreateMutatingTriangleLayer(BoundingBox envelope)
        {
            var layer = new MemoryLayer();

            var polygon = new Polygon(new LinearRing(GenerateRandomPoints(envelope, 3)));
            var feature = new Feature()
            {
                Geometry = polygon
            };
            var features = new Features();

            features.Add(feature);

            layer.DataSource = new MemoryProvider(features);

            PeriodicTask.Run(() =>
            {
                polygon.ExteriorRing = new LinearRing(GenerateRandomPoints(envelope, 3));
                // Clear cache for change to show
                feature.RenderedGeometry.Clear();
                // Trigger DataChanged notification
                layer.RefreshData(layer.Envelope, 1, true);
            },
                             TimeSpan.FromMilliseconds(1000));

            return(layer);
        }
Exemplo n.º 2
0
 private static void CarsLayerUpdate(MapControl myMapControl)
 {
     if (carsLayer == null)
     {
         var feature = new Feature
         {
             Geometry = new MultiPoint(carsMapPoints)
         };
         var provider = new MemoryProvider(feature);
         carsLayer = new MemoryLayer
         {
             DataSource = provider,
             Style      = new SymbolStyle
             {
                 Fill        = new Brush(new Color(0, 0, 0)),
                 SymbolScale = 0.25
             }
         };
         myMapControl.Map.Layers.Add(carsLayer);
     }
     else
     {
         carsLayer.DataSource = new MemoryProvider(
             new Feature
         {
             Geometry = new MultiPoint(carsMapPoints)
         });
         myMapControl.Refresh();
         //carsLayer.ClearCache();
         carsLayer.RefreshData(carsLayer.Envelope, 1, true); //.ViewChanged(true, carsLayer.Envelope, 1);
     }
 }
Exemplo n.º 3
0
        public void AddOffer(string name, double longitude, double latitude)
        {
            if (!featureMap.ContainsKey(name))
            {
                var polygon = new Polygon(new LinearRing());
                var point   = SphericalMercator.FromLonLat(longitude, latitude);

                var feature = new Feature();

                feature.Geometry  = point;
                feature["name"]   = name;
                feature["offers"] = 0;
                feature.Styles.Add(CreateOfferLabelStyle(name));

                var features = new List <IFeature>(offerMemoryProvider.Features);
                features.Add(feature);
                offerMemoryProvider.ReplaceFeatures(features);
                featureMap.Add(name, feature);
            }

            offerLayer.RefreshData(offerLayer.Envelope, 1, true);
        }
Exemplo n.º 4
0
        private static void TrafficLightsLayerUpdate(MapControl myMapControl)
        {
            if (redLightsLayer == null)
            {
                var feature = new Feature
                {
                    Geometry = new MultiPoint(redLightsPoints)
                };
                var provider = new MemoryProvider(feature);
                redLightsLayer = new MemoryLayer {
                    DataSource = provider, Style = new SymbolStyle {
                        Fill = new Brush(Color.Red), SymbolScale = 0.33
                    }
                };
                myMapControl.Map.Layers.Add(redLightsLayer);
            }
            else
            {
                redLightsLayer.DataSource = new MemoryProvider(new Feature {
                    Geometry = new MultiPoint(redLightsPoints)
                });
                myMapControl.Refresh();
                //redTrafficSignalsLayer.		ClearCache();
                redLightsLayer.RefreshData(redLightsLayer.Envelope, 1, true);  //ViewChanged(true, redTrafficSignalsLayer.Envelope, 1);
            }

            if (greenLightsLayer == null)
            {
                var feature = new Feature
                {
                    Geometry = new MultiPoint(greenLightsPoints)
                };
                var provider = new MemoryProvider(feature);
                greenLightsLayer = new MemoryLayer {
                    DataSource = provider, Style = new SymbolStyle {
                        Fill = new Brush(Color.Green), SymbolScale = 0.33
                    }
                };
                myMapControl.Map.Layers.Add(greenLightsLayer);
            }
            else
            {
                greenLightsLayer.DataSource = new MemoryProvider(new Feature {
                    Geometry = new MultiPoint(greenLightsPoints)
                });
                myMapControl.Refresh();
                //greenTrafficSignalsLayer.ClearCache();
                greenLightsLayer.RefreshData(greenLightsLayer.Envelope, 1, true); //ViewChanged(true, greenTrafficSignalsLayer.Envelope, 1);
            }
        }