Example #1
0
        private void RemoveMapData(DrawnMapData drawnMapDataToRemove)
        {
            drawnMapDataToRemove.Observer.Dispose();
            drawnMapDataList.Remove(drawnMapDataToRemove);

            map.Layers.Remove(drawnMapDataToRemove.FeatureBasedMapDataLayer);
        }
Example #2
0
        private void DrawMapData(FeatureBasedMapData featureBasedMapData)
        {
            IFeatureBasedMapDataLayer featureBasedMapDataLayer = FeatureBasedMapDataLayerFactory.Create(featureBasedMapData);

            var drawnMapData = new DrawnMapData
            {
                FeatureBasedMapData      = featureBasedMapData,
                FeatureBasedMapDataLayer = featureBasedMapDataLayer
            };

            drawnMapData.Observer = new Observer(() =>
            {
                mapDataLayersToUpdate.Add(drawnMapData.FeatureBasedMapDataLayer);
                StartUpdateTimer();
            })
            {
                Observable = featureBasedMapData
            };

            drawnMapDataList.Add(drawnMapData);

            if (!Projection.Equals(featureBasedMapDataLayer.Projection))
            {
                featureBasedMapDataLayer.Reproject(Projection);
            }

            map.Layers.Add(featureBasedMapDataLayer);
        }
Example #3
0
        /// <summary>
        /// Defines the area taken up by the visible map-data based on the provided map-data.
        /// </summary>
        /// <param name="mapData">The data to determine the visible extent for.</param>
        /// <returns>The area definition.</returns>
        /// <exception cref="ArgumentException">Thrown when <paramref name="mapData"/> is
        /// not part of the drawn map features.</exception>
        private Envelope CreateEnvelopeForVisibleLayers(MapData mapData)
        {
            if (mapData is MapDataCollection collection)
            {
                return(CreateEnvelopeForVisibleLayers(collection));
            }

            DrawnMapData drawnMapData = drawnMapDataList.FirstOrDefault(dmd => dmd.FeatureBasedMapData.Equals(mapData));

            if (drawnMapData == null)
            {
                throw new ArgumentException($@"Can only zoom to {nameof(MapData)} that is part of this {nameof(MapControl)}s drawn {nameof(mapData)}.",
                                            nameof(mapData));
            }

            var envelope = new Envelope();

            if (LayerHasVisibleExtent(drawnMapData.FeatureBasedMapDataLayer))
            {
                envelope.ExpandToInclude(drawnMapData.FeatureBasedMapDataLayer.Extent.ToEnvelope());
            }

            return(envelope);
        }