• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MapControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MapControl的典型用法代码示例。如果您正苦于以下问题:C# MapControl类的具体用法?C# MapControl怎么用?C# MapControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MapControl类属于命名空间,在下文中一共展示了MapControl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LineStringEditorCreationWithoutMapControlTest

        public void LineStringEditorCreationWithoutMapControlTest()
        {
            var mapControl = new MapControl();
            mapControl.Map.ZoomToFit(new Envelope(new Coordinate(0, 0), new Coordinate(1000, 1000)));
        
            var lineStringEditor = new LineStringInteractor(null, sampleFeature, GetStyle(), null);
            Assert.AreEqual(null, lineStringEditor.TargetFeature);
            Assert.AreNotEqual(null, lineStringEditor.SourceFeature);
            
            // There are no default focused trackers
            var trackers = lineStringEditor.Trackers.Where(t => t.Selected);
            Assert.AreEqual(0, trackers.Count());

            TrackerFeature tracker = lineStringEditor.Trackers[2];
            Assert.AreNotEqual(null, tracker);
            Assert.AreEqual(20.0, tracker.Geometry.Coordinates[0].X);
            Assert.AreEqual(0.0, tracker.Geometry.Coordinates[0].Y);

            lineStringEditor.Start();
            lineStringEditor.SetTrackerSelection(tracker, true);

            trackers = lineStringEditor.Trackers.Where(t => t.Selected);
            Assert.AreEqual(1, trackers.Count());
            Assert.AreNotEqual(null, lineStringEditor.TargetFeature);
            Assert.AreNotEqual(lineStringEditor.SourceFeature, lineStringEditor.TargetFeature);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:26,代码来源:LineStringInteractorTest.cs


示例2: addPinsToMap

        public void addPinsToMap(MapControl mapControl, Action<MapPin> tappedCallback = null)
        {
            removePinsFromMap(mapControl);
            m_mapPins = new List<MapPin>();

            int i = 1;
            DB_station prevStation = null;
            foreach (List<DB_station> route in m_routes)
            {
                foreach(DB_station station in route)
                {
                    if (station == prevStation || (station.latitude == 0f && station.longitude == 0f))
                        continue;

                    // Title for station.
                    string title = "Przystanek " + (i++) + "\n" + station.post_id + " " + station.post_name + "\n" + station.street;

                    // Add pin into map.
                    var location = new Geopoint(new BasicGeoposition()
                    {
                        Latitude = station.latitude,
                        Longitude = station.longitude
                    });
                    MapPin pin = new MapPin(title, station, MapPin.PinType.RegularPin, MapPin.PinSize.Small, tappedCallback);
                    pin.addToMap(mapControl, location);
                    m_mapPins.Add(pin);
                    prevStation = station;
                }
            }
        }
开发者ID:Lichwa,项目名称:JakDojadeXamarin,代码行数:30,代码来源:MapRoute.cs


示例3: LayersWindow

        public LayersWindow(MapControl mapControl)
        {
            InitializeComponent();
            _mapControl = mapControl;
            _model = new ObservableCollection<LayerViewModel>();
            if (mapControl.mapBox.Map.Layers != null && mapControl.mapBox.Map.Layers.Count > 0) {
                foreach (ILayer layer in mapControl.mapBox.Map.Layers) {
                    if (layer is VectorLayer) {
                        _model.Insert(0, new VectorLayerViewModel(layer as VectorLayer));
                    } else if (layer is MyGdalRasterLayer) {
                        _model.Insert(0, new RasterLayerViewModel(layer as MyGdalRasterLayer));
                    }
                }
            }

            lstLayers.ItemsSource = _model;

            if (_model.Count > 0) {
                lstLayers.SelectedIndex = 0;
            }

            MapBackColor = mapControl.mapBox.BackColor;

            backgroundColorPicker.DataContext = this;
        }
开发者ID:kehh,项目名称:biolink,代码行数:25,代码来源:LayersWindow.xaml.cs


示例4: PointMutatorCreationWithoutMapControlTest

        public void PointMutatorCreationWithoutMapControlTest()
        {
            MapControl mapControl = new MapControl();
            mapControl.Map.ZoomToBox(new Envelope(new Coordinate(0, 0), new Coordinate(1000, 1000)));
            ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl);
            LineStringEditor lineStringMutator = new LineStringEditor(coordinateConverter, null, sampleFeature, GetStyle());
            Assert.AreEqual(null, lineStringMutator.TargetFeature);
            Assert.AreNotEqual(null, lineStringMutator.SourceFeature);
            // There are no default focused trackers
            IList<ITrackerFeature> trackers = lineStringMutator.GetFocusedTrackers();
            Assert.AreEqual(0, trackers.Count);

            ITrackerFeature tracker = lineStringMutator.GetTrackerByIndex(2);
            Assert.AreNotEqual(null, tracker);
            Assert.AreEqual(20.0, tracker.Geometry.Coordinates[0].X);
            Assert.AreEqual(0.0, tracker.Geometry.Coordinates[0].Y);

            lineStringMutator.Start();
            lineStringMutator.Select(tracker, true);

            trackers = lineStringMutator.GetFocusedTrackers();
            Assert.AreEqual(1, trackers.Count);
            Assert.AreNotEqual(null, lineStringMutator.TargetFeature);
            Assert.AreNotEqual(lineStringMutator.SourceFeature, lineStringMutator.TargetFeature);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:LineStringMutatorTest.cs


示例5: Start

    void Start()
    {
        GameObject mapControlObj = GameObject.Find("MapControl");
        mapControl = mapControlObj.GetComponent<MapControl>();

        Transform textBox = transform.Find("UpperLeft/TextBox");
        mapControl.SetTextBox(textBox.GetComponent<MapTextBox>());

        upperLeft = transform.Find("UpperLeft");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(upperLeft);

        upperRight = transform.Find("UpperRight");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(upperRight);
        upperRight.gameObject.AddComponent<InputRepeater>().SetTarget(mapControl.transform);

        lowerLeft = transform.Find("LowerLeft");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(lowerLeft);
        Transform playerName = lowerLeft.Find("PlayerName");
        Transform playerScore = lowerLeft.Find("PlayerScore");

        lowerRight = transform.Find("LowerRight");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(lowerRight);
        Transform enemyName = lowerRight.Find("EnemyName");
        Transform enemyScore = lowerRight.Find("EnemyScore");

        mapControl.InitScoreboard(playerName, playerScore, enemyName, enemyScore);
    }
开发者ID:Diggery,项目名称:SuperSneak,代码行数:27,代码来源:MapUI.cs


示例6: SettingsManager

        public SettingsManager(ref MapControl MapMain)
        {
            // Check is the instance doesnt already exist.
            if (Current != null)
            {
                //if there is an instance in the app already present then simply throw an error.
                throw new Exception("Only one settings manager can exist in a App.");
            }

            // Setting the instance to the static instance field.
            Current = this;

            this.MapMain = MapMain;

            ApplicationData.Current.DataChanged += new TypedEventHandler<ApplicationData, object>(DataChangeHandler);

            // Roaming Settings
            RoamingSettings = ApplicationData.Current.RoamingSettings;

            RoamingSettings.CreateContainer("Map", ApplicationDataCreateDisposition.Always);
            RoamingSettings.CreateContainer("Appearance", ApplicationDataCreateDisposition.Always);
            

            // Local Settings
            LocalSettings = ApplicationData.Current.LocalSettings;

            LocalSettings.CreateContainer("Location", ApplicationDataCreateDisposition.Always);
        }
开发者ID:LdwgWffnschmdt,项目名称:CykeMaps,代码行数:28,代码来源:SettingsManager.cs


示例7: TilesLayer

 /// <summary>
 /// Creates a new feature layer for visualizing a map based of tiles.
 /// </summary>
 /// <param name="Id">The unique identification of the layer.</param>
 /// <param name="MapControl">The MapControl of the layer.</param>
 /// <param name="ZIndex">The Z-Index of the layer.</param>
 public TilesLayer(String Id,
                   MapControl  MapControl,
                   Int32       ZIndex)
     : this(Id, ZIndex, MapControl)
 {
     TilesRefreshTimer  = new Timer(TilesAutoRefresh, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(100));
 }
开发者ID:Vanaheimr,项目名称:Aegir,代码行数:13,代码来源:TilesLayer.cs


示例8: MapControl_OnMapTapped

        private void MapControl_OnMapTapped(MapControl sender, MapInputEventArgs args)
        {
            if (PushPins.Count > 0)
            {
                MyMapControl.MapElements.Remove(PushPin.Icon);
                PushPins.Clear();
            }

            Geopoint location = args.Location; // Download the complete position of tapped point

            //DownloadedLocation = location;

            CheckBorders.Check(location);

            if (CheckBorders.Check(location) == true)
            {

                PushPin.SetPosition(MyMapControl, location.Position.Latitude, location.Position.Longitude);

                PushPins.Add(PushPin);
            }
            else
            {
                MessageBox.ShowMessage("Obszar poza zasięgiem!");
            }

            
        }
开发者ID:Wizjonersky,项目名称:TaxiCalculator,代码行数:28,代码来源:MainPage.xaml.cs


示例9: MapsViewModel

        public MapsViewModel(MapControl mapControl)
        {
            _mapControl = mapControl;
            StopStreetViewCommand = new DelegateCommand(StopStreetView, () => IsStreetView);
            StartStreetViewCommand = new DelegateCommand(StartStreetViewAsync, () => !IsStreetView);

            if (!DesignMode.DesignModeEnabled)
            {
                _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            }

            _locator.StatusChanged += async (s, e) =>
            {
                await _dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                                PositionStatus = e.Status
                );
            };

            // intialize defaults at startup
            CurrentPosition = new Geopoint(new BasicGeoposition { Latitude = 48.2, Longitude = 16.3 });
            // { Latitude = 47.604, Longitude = -122.329 });
            CurrentMapStyle = MapStyle.Road;
            DesiredPitch = 0;
            ZoomLevel = 12;
        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:25,代码来源:MapsViewModel.cs


示例10: ClearSelectionOnParentGroupLayerRemove

        public void ClearSelectionOnParentGroupLayerRemove()
        {
            var featureProvider = new DataTableFeatureProvider();
            featureProvider.Add(new WKTReader().Read("POINT(0 0)"));
            var layer = new VectorLayer { DataSource = featureProvider };
            var groupLayer = new GroupLayer { Layers = { layer } };

            using (var mapControl = new MapControl { Map = { Layers = { groupLayer } }, AllowDrop = false })
            {
                var selectTool = mapControl.SelectTool;

                selectTool.Select(featureProvider.Features.Cast<IFeature>());

                WindowsFormsTestHelper.Show(mapControl);

                mapControl.Map.Layers.Remove(groupLayer);

                mapControl.WaitUntilAllEventsAreProcessed();

                selectTool.Selection
                    .Should("selection is cleared on layer remove").Be.Empty();
            }

            WindowsFormsTestHelper.CloseAll();
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:SelectToolTest.cs


示例11: myMap_MapTapped_1

 private void myMap_MapTapped_1(MapControl sender, MapInputEventArgs args)
 {
     Debug.WriteLine(args.Location);
     messageShown = false;
     pinOnMap = true;
     Controller.PinPosition = args.Location;
 }
开发者ID:wowinter13,项目名称:maPanic,代码行数:7,代码来源:MainPage.xaml.cs


示例12: MyMap_MapTapped

 private void MyMap_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     var tappedGeoPosition = args.Location.Position;
     var status = "MapTapped at \nLatitude:" + tappedGeoPosition.Latitude + "\nLongitude: " +
                  tappedGeoPosition.Longitude;
     //rootPage.NotifyUser(status, NotifyType.StatusMessage);
 }
开发者ID:wowinter13,项目名称:maPanic,代码行数:7,代码来源:GeoMapView.xaml.cs


示例13: GridProfileTool

        public GridProfileTool(MapControl mapControl)
            : base(mapControl)
        {

            GridProfiles = new List<IFeature>();

            VectorLayer profileLayer = new VectorLayer("Profile Layer")
                                           {
                                               DataSource = new FeatureCollection(GridProfiles, typeof(GridProfile)),
                                               Enabled = true,
                                               Style = new VectorStyle
                                                           {
                                                               Fill = new SolidBrush (Color.Tomato),
                                                               Symbol = null,
                                                               Line = new Pen(Color.SteelBlue, 1),
                                                               Outline = new Pen(Color.FromArgb(50, Color.LightGray), 3)
                                                           },
                                               Map = mapControl.Map,
                                               ShowInTreeView = true
                                           };
            Layer = profileLayer;

            newLineTool = new NewLineTool(profileLayer)
                              {
                                  MapControl = mapControl,
                                  Name = "ProfileLine",
                                  AutoCurve = false,
                                  MinDistance = 0,
                                  IsActive = false
                              };
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:31,代码来源:GridProfileTool.cs


示例14: MapLayer

 public MapLayer(MapControl control)
 {
     _control = control;
     _viewModel = _control.ViewModel;
     _settings = control.ViewModel.Settings;
     _renderBackground = control.ViewModel.Settings.RenderBackground;
 }
开发者ID:lltcggie,项目名称:StageMapEditor,代码行数:7,代码来源:MapLayer.cs


示例15: CanAddPointToPolygon

        public void CanAddPointToPolygon()
        {
            var mapControl = new MapControl();

            var vectorLayer = new VectorLayer();
            var layerData = new FeatureCollection();
            vectorLayer.DataSource = layerData;
            layerData.FeatureType = typeof(CloneableFeature);

            layerData.Add(new Polygon(new LinearRing(
                                           new[]
                                               {
                                                   new Coordinate(0, 0),
                                                   new Coordinate(100, 0),
                                                   new Coordinate(100, 100),
                                                   new Coordinate(0, 100),
                                                   new Coordinate(0, 0),
                                               })));

            mapControl.Map.Layers.Add(vectorLayer);

            var firstFeature = (IFeature)layerData.Features[0];
            mapControl.SelectTool.Select(firstFeature);

            var curveTool = mapControl.GetToolByType<CurvePointTool>();

            curveTool.IsActive = true;
            var args = new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0);
            curveTool.OnMouseMove(new Coordinate(50, 0), new MouseEventArgs(MouseButtons.None, 1, 0, 0, 0));
            curveTool.OnMouseDown(new Coordinate(50, 0), args);
            curveTool.OnMouseUp(new Coordinate(50, 0), args);

            Assert.AreEqual(6, firstFeature.Geometry.Coordinates.Length);
            Assert.AreEqual(50.0, firstFeature.Geometry.Coordinates[1].X);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:35,代码来源:CurvePointToolTest.cs


示例16: MapView

        public MapView()
        {

            mapControl = new MapControl();
            mapControl.ZoomInteractionMode = MapInteractionMode.GestureAndControl;
            mapControl.TiltInteractionMode = MapInteractionMode.GestureAndControl;
            mapControl.MapServiceToken = "ift37edNFjWtwMkOrquL~7gzuj1f0EWpVbWWsBaVKtA~Amh-DIg5R0ZPETQo7V-k2m785NG8XugPBOh52EElcvxaioPYSYWXf96wL6E_0W1g";

            // Specify a known location
            BasicGeoposition cityPosition;
            Geopoint cityCenter;

            cityPosition = new BasicGeoposition() { Latitude = 2.4448143, Longitude = -76.6147395 };
            cityCenter = new Geopoint(cityPosition);

            // Set map location
            mapControl.Center = cityCenter;
            mapControl.ZoomLevel = 13.0f;
            mapControl.LandmarksVisible = true;

            AddIcons();

            this.Children.Add(mapControl);


            //this.Children.Add(_map);
        }
开发者ID:simonbedoya,项目名称:PlansPop-W10,代码行数:27,代码来源:MapView.cs


示例17: NewNodeToolShouldWorkWithoutSnapRules

        public void NewNodeToolShouldWorkWithoutSnapRules()
        {
            // Create map and map control
            Map map = new Map();
            var nodeList = new List<Node>();

            var nodeLayer = new VectorLayer
                {
                    DataSource = new FeatureCollection(nodeList, typeof (Node)),
                    Visible = true,
                    Style = new VectorStyle
                        {
                            Fill = new SolidBrush(Color.Tomato),
                            Symbol = null,
                            Line = new Pen(Color.Turquoise, 3)
                        }
                };
            map.Layers.Add(nodeLayer);

            var mapControl = new MapControl {Map = map};
            mapControl.Resize += delegate { mapControl.Refresh(); };
            mapControl.Dock = DockStyle.Fill;

            var newNodeTool = new NewNetworkFeatureTool(l => true, "new node");
            mapControl.Tools.Add(newNodeTool);

            var args = new MouseEventArgs(MouseButtons.Left, 1, -1, -1, -1);

            newNodeTool.OnMouseDown(new Coordinate(0, 20), args);
            newNodeTool.OnMouseMove(new Coordinate(0, 20), args);
            newNodeTool.OnMouseUp(new Coordinate(0, 20), args);

            Assert.IsFalse(newNodeTool.IsBusy);
            Assert.AreEqual(1, nodeList.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:35,代码来源:NewNetworkFeatureToolTest.cs


示例18: DisablingLayerShouldRefreshMapControlOnce

        public void DisablingLayerShouldRefreshMapControlOnce()
        {
            using (var mapControl = new MapControl{ AllowDrop = false })
            {
                WindowsFormsTestHelper.Show(mapControl);

                mapControl.Map.Layers.Add(new GroupLayer("group1"));

                while (mapControl.IsProcessing)
                {
                    Application.DoEvents();
                }

                var refreshCount = 0;
                mapControl.MapRefreshed += delegate
                                               {
                                                   refreshCount++;
                                               };


                mapControl.Map.Layers.First().Visible = false;

                while (mapControl.IsProcessing)
                {
                    Application.DoEvents();
                }

                // TODO: currently second refresh can happen because of timer in MapControl - timer must be replaced by local Map / Layer / MapControl custom event
                refreshCount.Should("map should be refreshed once when layer property changes").Be.LessThanOrEqualTo(2);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:31,代码来源:MapControlTest.cs


示例19: CalculateRoute

        public static async void CalculateRoute(MapControl mapControl,double startLatitude, double startLongitude, double endLatitude, double endLongitude)
        {
           
            BasicGeoposition startLocation = new BasicGeoposition();
            startLocation.Latitude = startLatitude;
            startLocation.Longitude = startLongitude;
            Geopoint startPoint = new Geopoint(startLocation);

            BasicGeoposition endLocation = new BasicGeoposition();
            endLocation.Latitude = endLatitude;
            endLocation.Longitude = endLongitude;
            Geopoint endPoint = new Geopoint(endLocation);

            MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(
                startPoint,
                endPoint,
                MapRouteOptimization.Time,
                MapRouteRestrictions.None);

            if (routeResult.Status == MapRouteFinderStatus.Success)
            {
                MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
                viewOfRoute.RouteColor = Colors.Aqua;
                viewOfRoute.OutlineColor = Colors.Black;

                mapControl.Routes.Add(viewOfRoute);

                await mapControl.TrySetViewBoundsAsync(
                    routeResult.Route.BoundingBox,
                    null,
                    Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow);

                var distance = routeResult.Route.LengthInMeters.ToString();
            }
        }
开发者ID:Wizjonersky,项目名称:TaxiCalculator,代码行数:35,代码来源:RouteCalculator.cs


示例20: ActualDeleteTriggersBeginEdit

        public void ActualDeleteTriggersBeginEdit()
        {
            MapControl mapControl = new MapControl();

            SelectTool selectTool = mapControl.SelectTool;

            VectorLayer vectorLayer = new VectorLayer();
            FeatureCollection layer2Data = new FeatureCollection();
            vectorLayer.DataSource = layer2Data;
            layer2Data.FeatureType = typeof(Feature);

            layer2Data.Add(new Point(4, 5));
            layer2Data.Add(new Point(0, 1));
            mapControl.Map.Layers.Add(vectorLayer);

            var featureMutator = mocks.StrictMock<IFeatureInteractor>();
            var editableObject = mocks.StrictMock<IEditableObject>();

            featureMutator.Expect(fm => fm.EditableObject).Return(editableObject).Repeat.Any();
            featureMutator.Expect(fm => fm.AllowDeletion()).Return(true).Repeat.Any();
            featureMutator.Expect(fm => fm.Delete()).Repeat.Once();
            editableObject.Expect(eo => eo.BeginEdit(null)).IgnoreArguments().Repeat.Once(); //expect BeginEdit!
            editableObject.Expect(eo => eo.EndEdit()).IgnoreArguments().Repeat.Once();

            mocks.ReplayAll();

            selectTool.Select((IFeature)layer2Data.Features[0]);

            selectTool.SelectedFeatureInteractors.Clear();
            selectTool.SelectedFeatureInteractors.Add(featureMutator); //inject our own feature editor

            mapControl.DeleteTool.DeleteSelection();

            mocks.VerifyAll();
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:35,代码来源:DeleteToolTest.cs



注:本文中的MapControl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MapData类代码示例发布时间:2022-05-24
下一篇:
C# Map类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap