Ejemplo n.º 1
0
 /// <summary>
 /// Zooms to the envelope if no envelope has been established for this frame.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void Layers_LayerAdded(object sender, LayerEventArgs e)
 {
     if (ExtentsInitialized) return;
     ExtentsInitialized = true;
     if (e.Layer != null)
     {
         ViewExtents = e.Layer.Extent.Copy();
         ViewExtents.ExpandBy(e.Layer.Extent.Width / 10, e.Layer.Extent.Height / 10);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create search layer
        /// </summary>
        public IEnumerable<IMapPointLayer> Create()
        {
            var ext = new Extent();
            Debug.WriteLine("Starting Create method");
            if (!_searchResult.ResultItems.Any())
            {
                Debug.WriteLine("Returning new point layer");
                return new List<IMapPointLayer>();
            }

            Debug.WriteLine("Getting data sites layer...");
            var root = _map.GetDataSitesLayer(true);
            Debug.WriteLine("Done");

            var layersToSelect = new List<MapPointLayer>();
            var result = new List<IMapPointLayer>();
            Debug.WriteLine("Starting loop, count: " + _searchResult.ResultItems.Count());
            foreach(var item in _searchResult.ResultItems)
            {
                try
                {
                    Debug.WriteLine("creating search result layer");
                    var subResultLayer = CreateSearchResultLayer(item, root);
                    Debug.WriteLine("Done; adding subResultLayer to list of result layers");
                    result.Add(subResultLayer);
                    Debug.WriteLine("Done; adding subResultLayer to root");
                    root.Add(subResultLayer);
                    Debug.WriteLine("Done; adding subResultLayer to layersToSelect");
                    layersToSelect.Add(subResultLayer);
                    Debug.WriteLine("Done with loop iteration");
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Exception: " + e.Message);
                    Debug.WriteLine(e.StackTrace);
                }
            }
            Debug.WriteLine("Loop Done, refreshing map");
            _map.Refresh();
            Debug.WriteLine("Done");

            Debug.WriteLine("Starting another loop");
            //assign the projection again
            foreach (var item in _searchResult.ResultItems)
            {
                item.FeatureSet.Reproject(_map.Projection);
                ext.ExpandToInclude(item.FeatureSet.Extent);
            }
            Debug.WriteLine("Loop done. Now looping through layers: " + root.Layers.Count);
            for (int i = 0; i < root.Layers.Count; i++)
            {
                var layer = root[i];
                var state = layersToSelect.Contains(layer);
                var rendItem = layer as IRenderableLegendItem;
                if (rendItem != null)
                {
                    rendItem.IsVisible = state; // force a re-draw in the case where we are talking about layers.
                }
                else
                {
                    layer.Checked = state;
                }
            }
            Debug.WriteLine("End loop");

            ext.ExpandBy(_map.ViewExtents.Width / 100);
            _map.ViewExtents = ext;
            _map.Refresh();

            Debug.WriteLine("Return result");
            return result;
        }