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);
        }
Esempio n. 2
0
        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;
        }
        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!");
            }

            
        }
        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;
        }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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
                              };
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
 public MapLayer(MapControl control)
 {
     _control = control;
     _viewModel = _control.ViewModel;
     _settings = control.ViewModel.Settings;
     _renderBackground = control.ViewModel.Settings.RenderBackground;
 }
Esempio n. 11
0
 private void myMap_MapTapped_1(MapControl sender, MapInputEventArgs args)
 {
     Debug.WriteLine(args.Location);
     messageShown = false;
     pinOnMap = true;
     Controller.PinPosition = args.Location;
 }
Esempio n. 12
0
        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);
            }
        }
        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();
            }
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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);
        }
        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);
        }
Esempio n. 19
0
        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;
                }
            }
        }
Esempio n. 20
0
 /// <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));
 }
Esempio n. 21
0
        public void DisablingLayerShouldRefreshMapControlOnce()
        {
            var mapControl = new MapControl();
            WindowsFormsTestHelper.Show(mapControl);

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

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

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

            
            mapControl.Map.Layers.First().Enabled = false;
            
            while (mapControl.IsProcessing)
            {
                Application.DoEvents();
            }
            
            refreshCount.Should("map should be refreshed once when layer property changes").Be.EqualTo(1);
        }
Esempio n. 22
0
 /// <summary>
 /// Creates the north arrow layout component showing a specified bitmap.
 /// </summary>
 /// <param name="northArrowBitmap">The bitmap image to show</param>
 /// <param name="mapControl">The map control it operates on</param>
 public NorthArrowTool(Bitmap northArrowBitmap, MapControl mapControl) : base(mapControl)
 {
     this.northArrowBitmap = northArrowBitmap;
     // The size of this component is defined by the size of the bitmap
     size = northArrowBitmap.Size;
     Name = "NorthArrow";
 }
 public MapControlWindow()
 {
     InitializeComponent();
     _mapControl = this.mapControl;
     viewModel = new MapControlWindow_ViewModel();
     viewModel.UpdateMapControlContent();
     DataContext = viewModel;
 }
Esempio n. 24
0
 /// <summary>
 /// Creates the north arrow layout component showing default bitmap.
 /// </summary>
 /// <param name="northArrowBitmap">The bitmap image to show</param>
 /// <param name="mapControl">The map control it operates on</param>
 public NorthArrowTool(MapControl mapControl)
     : base(mapControl)
 {
     this.northArrowBitmap = DefaultNorthArrow();
     Size = new Size(side,side);
     Name = "NorthArrow";
     ImageIsVectorBased = true;
 }
Esempio n. 25
0
 public void StartTurn(MapControl newMapControl)
 {
     mapControl = newMapControl;
     mapControl.DisplayMessage("The enemy has made\nan move", 3);
     capturePoint = CaptureFromLeadPoint();
     Camera.main.transform.parent.GetComponent<MapCameraControl>().SetFocus(capturePoint);
     Invoke("CapturePoint", 3);
 }
Esempio n. 26
0
        /// <summary>
        /// Creates a new edit feature layer for adding, editing and visualizing map features.
        /// </summary>
        /// <param name="Name">The identification string of this feature layer.</param>
        /// <param name="MapControl">The parent map control.</param>
        /// <param name="ZIndex">The z-index of this feature layer.</param>
        public EditFeatureLayer(String Id, MapControl MapControl, Int32 ZIndex)
            : base(Id, MapControl, ZIndex)
        {
            this.Background = new SolidColorBrush(Colors.Transparent);

            // Register mouse events
            this.PreviewMouseRightButtonDown += ProcessPreviewMouseRightButtonDown;
        }
Esempio n. 27
0
 public void MapToolMessageBoxDisabledTest()
 {
     var demoMapTool = new MapToolMessageBox();
     var mapControl = new MapControl() { Map = new Map(new Size(100, 100)) };
     mapControl.Tools.Add(demoMapTool);
     mapControl.ActivateTool(demoMapTool);
     demoMapTool.Disable();
     WindowsFormsTestHelper.ShowModal(mapControl);
 }
Esempio n. 28
0
        public async override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> state)
        {
            try
            {
                Location = SessionState[Constants.MapLocationKey] as Home;
                MainMapControl = (NavigationService.Content as MapPage).FindName("MainMapControl") as MapControl;       //Pull our MainMapControl from the XAML.


                if (!Location.HasValidAddress())
                {
                    if (!Location.HasValidCoordinates())
                        throw new InvalidOperationException("Selected location has invalid criteria");

                    var latitude = Location.Location.Latitude.Value;
                    var longitude = Location.Location.Longitude.Value;
                    SetMapPointFromCoordinates(latitude, longitude);
                }

                else
                {
                    //Assume it's an address
                    if (await LocationService.Current.RequestLocationAccess())
                    {
                        #region Get access to current location

                        var pos = await LocationService.Current.Locator.GetGeopositionAsync();
                        #endregion Get access to current location

                        #region Search addresses
                        //When searching, it will favor addresses near this location
                        var queryHint = new BasicGeoposition
                        {
                            Latitude = pos.Coordinate.Point.Position.Latitude,
                            Longitude = pos.Coordinate.Point.Position.Longitude
                        };

                        var hintPoint = new Geopoint(queryHint);
                        var result = await MapLocationFinder.FindLocationsAsync(Location.Name, hintPoint);
                        #endregion Search addresses

                        if (result.Status == MapLocationFinderStatus.Success && result.Locations.Count > 0)
                            SetMapPointFromCoordinates(result.Locations[0].Point.Position.Latitude, result.Locations[0].Point.Position.Longitude);
                    }
                    else
                    {
                        
                    }
                  
                }
            }
            catch (UnauthorizedAccessException)
            {
                IsLocationAvailable = false;
            }

            await Task.CompletedTask;
        }
Esempio n. 29
0
 public MousePosition(MapControl mapControl)
     : this()
 {
     var mappos = Mouse.GetPosition(mapControl.Wrapper);
     ElementPosition = mappos;
     Position = new Point((int)mappos.X, (int)mappos.Y);
     var g = Model.GridSize * Scale;
     GridPoint = new Point((int)(Position.X / g), (int)(Position.Y / g));
 }
 public VindRitBob()
 {
     this.InitializeComponent();
     if (MapVindRit == null)
     {
         MapVindRit = new MapControl();
     }
     Vm.Map = MapVindRit;
 }
Esempio n. 31
0
 public bool safeGap(Vector2 position)
 {
     return(MapControl.safeGap(position));
 }
Esempio n. 32
0
 internal void InvokePostPaint(NamedElement sender)
 {
     MapControl.OnPostPaint(MapControl, new MapPaintEventArgs(MapControl, sender, graph));
 }
Esempio n. 33
0
        private async void MapControl_MapClicked(object sender, MapClickedEventArgs e)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;
                if (PageStatusEnum == PageStatusEnum.Searching)
                {
                    var mapSpan = Xamarin.Forms.GoogleMaps.MapSpan.FromCenterAndRadius(new Xamarin.Forms.GoogleMaps.Position(e.Point.Latitude, e.Point.Longitude), Xamarin.Forms.GoogleMaps.Distance.FromKilometers(1));

                    MapControl.MoveToRegion(mapSpan);

                    //Location Geocoding
                    var locations = await Geocoding.GetPlacemarksAsync(new Location(e.Point.Latitude, e.Point.Longitude));

                    var locationDecoded = locations?.FirstOrDefault();

                    //Setting Pin
                    if (OrderStateEnum == OrderStateEnum.StartPicker)
                    {
                        _startLocation = e.Point;

                        var pin = MapControl.Pins.FirstOrDefault(x => x.Label == "Start");
                        if (pin != null)
                        {
                            pin.Position = new Position(_startLocation.Latitude, _startLocation.Longitude);
                        }
                        else
                        {
                            MapControl.Pins.Add(new Xamarin.Forms.GoogleMaps.Pin
                            {
                                Type     = PinType.Place,
                                Position = new Position(_startLocation.Latitude, _startLocation.Longitude),
                                Label    = "Start",
                                Icon     = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_pickuplocation.png") : BitmapDescriptorFactory.FromView(new Image()
                                {
                                    Source = "ic_pickuplocation.png", WidthRequest = 25, HeightRequest = 25
                                }),
                                Tag = 1
                            });
                        }



                        StartText = locationDecoded.Thoroughfare + " " + locationDecoded.FeatureName + ", " + locationDecoded.SubAdminArea;
                    }
                    else
                    {
                        _destinationLocation = e.Point;

                        var pin = MapControl.Pins.FirstOrDefault(x => x.Label == "Destination");
                        if (pin != null)
                        {
                            pin.Position = new Position(_destinationLocation.Latitude, _destinationLocation.Longitude);
                        }
                        else
                        {
                            MapControl.Pins.Add(new Xamarin.Forms.GoogleMaps.Pin
                            {
                                Type     = PinType.Place,
                                Position = new Position(_destinationLocation.Latitude, _destinationLocation.Longitude),
                                Label    = "Destination",
                                Icon     = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_pickuplocation.png") : BitmapDescriptorFactory.FromView(new Image()
                                {
                                    Source = "ic_pickuplocation.png", WidthRequest = 25, HeightRequest = 25
                                }),
                                Tag = 2
                            });
                        }

                        DestinationText = locationDecoded.Thoroughfare + " " + locationDecoded.FeatureName + ", " + locationDecoded.SubAdminArea;
                    }

                    CanCalculate = _startLocation != null && _destinationLocation != null;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 34
0
 public ZoomHistoryTool(MapControl mapControl) : base(mapControl)
 {
     Name = "ZoomHistory";
 }
Esempio n. 35
0
 /// <summary>
 /// 地图中心移动
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void MapCenterChanged(MapControl sender, object args)
 {
     _locationMoveTimer.Change(1200, Timeout.Infinite);
 }
 private void MyMap_MapContextRequested(MapControl sender, MapContextRequestedEventArgs args)
 {
     contextMenu.ShowAt(sender, args.Position);
 }
Esempio n. 37
0
 private void MapControl_ActualCameraChanged(MapControl sender, MapActualCameraChangedEventArgs args)
 {
     com.codename1.googlemaps.MapContainer.fireMapChangeEvent(mapId, (int)mapControl.ZoomLevel, mapControl.Center.Position.Latitude, mapControl.Center.Position.Longitude);
 }
Esempio n. 38
0
 private void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     RunMapRightTapped(Map, args.Location);
 }
Esempio n. 39
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            MapControl       = Map;
            StaticMapView    = this;
            StaticSearchGrid = Searchgrid;
            var AllowOverstretch     = SettingsSetters.GetAllowOverstretch();
            var FadeAnimationEnabled = SettingsSetters.GetFadeAnimationEnabled();

            if (InternalHelper.InternetConnection())
            {
                if (App.Current.RequestedTheme == ApplicationTheme.Light)
                {
                    ChangeViewControl.UseGoogleMaps(MapMode.Standard, AllowOverstretch: AllowOverstretch, IsFadingEnabled: FadeAnimationEnabled, showtraffic: SettingsSetters.GetShowTrafficOnLaunch());
                }
                else
                {
                    ChangeViewControl.UseGoogleMaps(MapMode.RoadsOnly, AllowOverstretch: AllowOverstretch, IsFadingEnabled: FadeAnimationEnabled, showtraffic: SettingsSetters.GetShowTrafficOnLaunch());
                }
            }
            else
            {
                Map.TileSources.Add(new MapTileSource(new LocalMapTileDataSource("ms-appdata:///local/MahMaps/mah_x_{x}-y_{y}-z_{zoomlevel}.jpeg"))
                {
                    AllowOverstretch = false, IsFadingEnabled = FadeAnimationEnabled
                });
            }
            inkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch;
            var drawingAttr = this.inkCanvas.InkPresenter.CopyDefaultDrawingAttributes();

            drawingAttr.PenTip         = PenTipShape.Rectangle;
            drawingAttr.Size           = new Size(4, 4);
            drawingAttr.IgnorePressure = true;
            drawingAttr.Color          = (Color)Resources["SystemControlBackgroundAccentBrush"];
            this.inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttr);
            if (e.Parameter != null)
            {
                //Google Maps Override
                if (e.Parameter.ToString().StartsWith("http"))
                {
                    //Search Uri association handler
                    if (((Uri)e.Parameter).Segments[2].ToLower() == "search/")
                    {
                        //Searchgrid.PopUP = true;
                        //Searchgrid.SearchText = ((Uri)e.Parameter).DecodeQueryParameters().Where(x => x.Key == "query").FirstOrDefault().Value;
                    }
                    //Directions Uri association handler
                    if (((Uri)e.Parameter).Segments[2].ToLower() == "dir/")
                    {
                        var parameters  = ((Uri)e.Parameter).DecodeQueryParameters();
                        var origin      = parameters.Where(x => x.Key == "origin").FirstOrDefault();
                        var destination = parameters.Where(x => x.Key == "destination").FirstOrDefault();
                        var travelmode  = parameters.Where(x => x.Key == "travelmode").FirstOrDefault();
                        var waypoints   = parameters.Where(x => x.Key == "waypoints").FirstOrDefault();
                        ViewModel.DirectionsControls.DirectionsHelper.DirectionModes Mode = ViewModel.DirectionsControls.DirectionsHelper.DirectionModes.walking;
                        Geopoint OriginPoint        = null;
                        Geopoint DestinationPoint   = null;
                        List <BasicGeoposition> lst = null;
                        if (travelmode.Value != null)
                        {
                            if (travelmode.Value.ToString() == "driving")
                            {
                                Mode = ViewModel.DirectionsControls.DirectionsHelper.DirectionModes.driving;
                            }
                            else if (travelmode.Value.ToString() == "bicycling ")
                            {
                                Mode = ViewModel.DirectionsControls.DirectionsHelper.DirectionModes.bicycling;
                            }
                            else if (travelmode.Value.ToString() == "transit")
                            {
                                Mode = ViewModel.DirectionsControls.DirectionsHelper.DirectionModes.transit;
                            }
                        }
                        if (origin.Value != null)
                        {
                            var latlng    = origin.Value.Split(',');
                            var Latitude  = Convert.ToDouble(latlng[0]);
                            var Longitude = Convert.ToDouble(latlng[1]);
                            OriginPoint = new Geopoint(new BasicGeoposition()
                            {
                                Latitude  = Latitude,
                                Longitude = Longitude
                            });
                        }
                        if (destination.Value != null)
                        {
                            var latlng    = destination.Value.Split(',');
                            var Latitude  = Convert.ToDouble(latlng[0]);
                            var Longitude = Convert.ToDouble(latlng[1]);
                            DestinationPoint = new Geopoint(new BasicGeoposition()
                            {
                                Latitude  = Latitude,
                                Longitude = Longitude
                            });
                        }
                        if (waypoints.Value != null)
                        {
                            lst = new List <BasicGeoposition>();
                            var latlngs = destination.Value.Split('|');
                            foreach (var item in latlngs)
                            {
                                var latlng             = item.Split(',');
                                BasicGeoposition point = new BasicGeoposition();
                                point.Latitude  = Convert.ToDouble(latlng[0]);
                                point.Longitude = Convert.ToDouble(latlng[1]);
                                lst.Add(point);
                            }
                        }
                        if (OriginPoint != null && DestinationPoint != null)
                        {
                            ViewModel.DirectionsControls.DirectionsHelper.Rootobject Result = null;
                            if (lst == null)
                            {
                                Result = await ViewModel.DirectionsControls.DirectionsHelper.GetDirections(OriginPoint.Position, DestinationPoint.Position, Mode);
                            }
                            else
                            {
                                Result = await ViewModel.DirectionsControls.DirectionsHelper.GetDirections(OriginPoint.Position, DestinationPoint.Position, Mode, lst);
                            }
                            if (Result != null)
                            {
                                Map.MapElements.Add(ViewModel.DirectionsControls.DirectionsHelper.GetDirectionAsRoute(Result, (Color)Resources["SystemControlBackgroundAccentBrush"]));
                            }
                        }
                    }
                    //Display a map
                    if (((Uri)e.Parameter).Segments[2].ToLower().StartsWith("@"))
                    {
                        await Task.Delay(1500);

                        try
                        {
                            if (!e.Parameter.ToString().Contains("searchplace"))
                            {
                                var parameters = ((Uri)e.Parameter).DecodeQueryParameters();
                                var mapaction  = parameters.Where(x => x.Key == "map_action").FirstOrDefault();
                                if (mapaction.Value != null && mapaction.Value == "pano")
                                {
                                    await new MessageDialog("StreetView Not Supported yet").ShowAsync();
                                }
                                var center = parameters.Where(x => x.Key == "center").FirstOrDefault();
                                var zoom   = parameters.Where(x => x.Key == "zoom").FirstOrDefault();
                                var cp     = center.Value.Split(',');
                                BasicGeoposition pointer = new BasicGeoposition()
                                {
                                    Latitude = Convert.ToDouble(cp[0]), Longitude = Convert.ToDouble(cp[1])
                                };
                                Map.Center = new Geopoint(pointer);
                                if (zoom.Value != null)
                                {
                                    await Map.TryZoomToAsync(Convert.ToDouble(zoom.Value));
                                }
                                RunMapRightTapped(Map, new Geopoint(pointer));
                            }
                            else
                            {
                                var search = ((Uri)e.Parameter).ToString().Replace("https://google.com/maps/@searchplace=", "");
                                //var search = parameters.Where(x => x.Key == "searchplace").FirstOrDefault();
                                var res = await ViewModel.PlaceControls.SearchHelper.TextSearch(search, Location : Map.Center, Radius : 15000);

                                if (res == null || res.results.Length == 0)
                                {
                                    await new MessageDialog("No search results found").ShowAsync();
                                    return;
                                }
                                var ploc     = res.results.FirstOrDefault().geometry.location;
                                var geopoint = new Geopoint(new BasicGeoposition()
                                {
                                    Latitude = ploc.lat, Longitude = ploc.lng
                                });
                                Map.Center = geopoint;
                                await MapView.MapControl.TryZoomToAsync(16);

                                SearchResultPoint = geopoint;
                            }
                        }
                        catch
                        {
                        }
                    }
                }

                //Windows Maps Override
                else
                {
                    var    parameters = ((Uri)e.Parameter).DecodeQueryParameters();
                    string cp         = "";
                    int    zoomlevel  = 0;
                    string Querry     = "";
                    string Where      = "";
                    //{bingmaps:?where=Tabarsi Square%2C north side of the Shrine%2C Mashhad%2C 2399%2C Īrān}
                    if (parameters.Where(x => x.Key == "where").Any())
                    {
                        Where = Uri.UnescapeDataString(parameters.Where(x => x.Key == "where").FirstOrDefault().Value.NoHTMLString());
                    }
                    if (parameters.Where(x => x.Key == "cp").Any())
                    {
                        cp = parameters.Where(x => x.Key == "cp").FirstOrDefault().Value;
                    }
                    if (parameters.Where(x => x.Key == "lvl").Any())
                    {
                        zoomlevel = Convert.ToInt32(parameters.Where(x => x.Key == "lvl").FirstOrDefault().Value);
                    }
                    if (parameters.Where(x => x.Key == "q").Any())
                    {
                        Querry = parameters.Where(x => x.Key == "q").FirstOrDefault().Value;
                    }
                    if (parameters.Where(x => x.Key == "collection").Any())
                    {
                        var point     = parameters.Where(x => x.Key == "collection").FirstOrDefault().Value;
                        var pointargs = point.Split('_');
                        var latitude  = pointargs[0].Split('.')[1] + "." + pointargs[0].Split('.')[2];
                        var longitude = pointargs[1];
                        cp = $"{latitude}~{longitude}";
                        if (parameters.Count >= 3)
                        {
                            Map.MapElements.Add(new MapIcon()
                            {
                                Location = new Geopoint(new BasicGeoposition()
                                {
                                    Latitude = Convert.ToDouble(latitude), Longitude = Convert.ToDouble(longitude)
                                }), Title = pointargs[2].Replace("+", " ")
                            });
                        }
                        else
                        {
                            Map.MapElements.Add(new MapIcon()
                            {
                                Location = new Geopoint(new BasicGeoposition()
                                {
                                    Latitude = Convert.ToDouble(latitude), Longitude = Convert.ToDouble(longitude)
                                }), Title = "Point"
                            });
                        }
                    }
                    if (Where != "")
                    {
                        await Task.Delay(500);

                        var res = await SearchHelper.TextSearch(Where);

                        if (res != null)
                        {
                            if (res.results != null && res.results.Any())
                            {
                                var loc = res.results.FirstOrDefault().geometry.location;
                                //var rgc = await ReverseGeoCode.GetLocation(Where);
                                Map.Center = new Geopoint(new BasicGeoposition()
                                {
                                    Latitude = loc.lat, Longitude = loc.lng
                                });
                                LastRightTap = new Geopoint(new BasicGeoposition()
                                {
                                    Latitude = loc.lat, Longitude = loc.lng
                                });
                                RunMapRightTapped(Map, LastRightTap);
                            }
                            else
                            {
                                var rgc = await ReverseGeoCode.GetLocation(Where);

                                Map.Center = rgc;
                            }
                        }
                        else
                        {
                            var rgc = await ReverseGeoCode.GetLocation(Where);

                            Map.Center = rgc;
                        }
                    }
                    if (cp != "")
                    {
                        await Task.Delay(500);

                        var bgp = new BasicGeoposition();
                        bgp.Latitude  = Convert.ToDouble(cp.Split('~')[0]);
                        bgp.Longitude = Convert.ToDouble(cp.Split('~')[1]);
                        Map.Center    = new Geopoint(bgp);
                        Map.MapElements.Add(new MapIcon()
                        {
                            Location = new Geopoint(bgp), Title = "Point"
                        });
                    }
                    if (zoomlevel != 0)
                    {
                        await Map.TryZoomToAsync(zoomlevel);
                    }
                    else
                    {
                        await MapView.MapControl.TryZoomToAsync(16);
                    }
                    if (Querry != "")
                    {
                        await Task.Delay(1500);

                        Searchbar.SearchQuerry = Querry;
                    }
                }
            }

            if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
            {
                var ac    = new Windows.UI.Xaml.Media.AcrylicBrush();
                var brush = Resources["SystemControlChromeLowAcrylicWindowBrush"] as Windows.UI.Xaml.Media.AcrylicBrush;
                ac                      = brush;
                ac.TintOpacity          = 0.8;
                ac.BackgroundSource     = Windows.UI.Xaml.Media.AcrylicBackgroundSource.Backdrop;
                InfoPane.PaneBackground = ac;
            }

            //MapViewVM.LoadPage();
        }
Esempio n. 40
0
        private void OnBeforeDraw()
        {
            MapControl map = GameScene.Scene.MapControl;

            if (map == null || !Visible)
            {
                return;
            }

            //int index = map.BigMap <= 0 ? map.MiniMap : map.BigMap;
            int index = map.BigMap;

            if (index <= 0)
            {
                if (Visible)
                {
                    Visible = false;
                }
                return;
            }

            TrySort();

            Rectangle viewRect = new Rectangle(0, 0, 600, 400);

            Size = Libraries.MiniMap.GetSize(index);

            if (Size.Width < 600)
            {
                viewRect.Width = Size.Width;
            }

            if (Size.Height < 400)
            {
                viewRect.Height = Size.Height;
            }

            viewRect.X = (Settings.ScreenWidth - viewRect.Width) / 2;
            viewRect.Y = (Settings.ScreenHeight - 120 - viewRect.Height) / 2;

            Location = viewRect.Location;
            Size     = viewRect.Size;

            float scaleX = Size.Width / (float)map.Width;
            float scaleY = Size.Height / (float)map.Height;

            viewRect.Location = new Point(
                (int)(scaleX * MapObject.User.CurrentLocation.X) - viewRect.Width / 2,
                (int)(scaleY * MapObject.User.CurrentLocation.Y) - viewRect.Height / 2);

            if (viewRect.Right >= Size.Width)
            {
                viewRect.X = Size.Width - viewRect.Width;
            }
            if (viewRect.Bottom >= Size.Height)
            {
                viewRect.Y = Size.Height - viewRect.Height;
            }

            if (viewRect.X < 0)
            {
                viewRect.X = 0;
            }
            if (viewRect.Y < 0)
            {
                viewRect.Y = 0;
            }

            Libraries.MiniMap.Draw(index, Location, Size, Color.FromArgb(255, 255, 255));

            int startPointX = (int)(viewRect.X / scaleX);
            int startPointY = (int)(viewRect.Y / scaleY);

            for (int i = MapControl.Objects.Count - 1; i >= 0; i--)
            {
                MapObject ob = MapControl.Objects[i];


                if (ob.Race == ObjectType.Item || ob.Dead || ob.Race == ObjectType.Spell)
                {
                    continue;                                                                       // || (ob.ObjectID != MapObject.User.ObjectID)
                }
                float x = ((ob.CurrentLocation.X - startPointX) * scaleX) + Location.X;
                float y = ((ob.CurrentLocation.Y - startPointY) * scaleY) + Location.Y;

                Color colour;

                if ((GroupDialog.GroupList.Contains(ob.Name) && MapObject.User != ob) || ob.Name.EndsWith(string.Format("({0})", MapObject.User.Name)))
                {
                    colour = Color.FromArgb(0, 0, 255);
                }
                else
                if (ob is PlayerObject)
                {
                    colour = Color.FromArgb(255, 255, 255);
                }
                else if (ob is NPCObject || ob.AI == 6)
                {
                    colour = Color.FromArgb(0, 255, 50);
                }
                else
                {
                    colour = Color.FromArgb(255, 0, 0);
                }

                DXManager.Sprite.Draw2D(DXManager.RadarTexture, Point.Empty, 0, new PointF((int)(x - 0.5F), (int)(y - 0.5F)), colour);
            }


            if (GameScene.Scene.MapControl.AutoPath)
            {
                foreach (var node in GameScene.Scene.MapControl.CurrentPath)
                {
                    Color colour = Color.White;

                    float x = ((node.Location.X - startPointX) * scaleX) + Location.X;
                    float y = ((node.Location.Y - startPointY) * scaleY) + Location.Y;

                    DXManager.Sprite.Draw2D(DXManager.RadarTexture, Point.Empty, 0, new PointF((int)(x - 0.5F), (int)(y - 0.5F)), colour);
                }
            }
        }
Esempio n. 41
0
        private void OnMouseClick(object sender, MouseEventArgs e)
        {
            MapControl map = GameScene.Scene.MapControl;

            if (map == null || !Visible)
            {
                return;
            }

            float scaleX = Size.Width / (float)map.Width;
            float scaleY = Size.Height / (float)map.Height;

            int index = map.BigMap;

            if (index <= 0)
            {
                if (Visible)
                {
                    Visible = false;
                }
                return;
            }

            Rectangle viewRect = new Rectangle(0, 0, 600, 400);

            Size = Libraries.MiniMap.GetSize(index);

            if (Size.Width < 600)
            {
                viewRect.Width = Size.Width;
            }

            if (Size.Height < 400)
            {
                viewRect.Height = Size.Height;
            }

            viewRect.X = (Settings.ScreenWidth - viewRect.Width) / 2;
            viewRect.Y = (Settings.ScreenHeight - 120 - viewRect.Height) / 2;

            viewRect.Location = new Point(
                (int)(scaleX * MapObject.User.CurrentLocation.X) - viewRect.Width / 2,
                (int)(scaleY * MapObject.User.CurrentLocation.Y) - viewRect.Height / 2);

            if (viewRect.Right >= Size.Width)
            {
                viewRect.X = Size.Width - viewRect.Width;
            }
            if (viewRect.Bottom >= Size.Height)
            {
                viewRect.Y = Size.Height - viewRect.Height;
            }

            if (viewRect.X < 0)
            {
                viewRect.X = 0;
            }
            if (viewRect.Y < 0)
            {
                viewRect.Y = 0;
            }

            int startPointX = (int)(viewRect.X / scaleX);
            int startPointY = (int)(viewRect.Y / scaleY);

            int X = (int)Math.Floor(((e.X - Location.X) / scaleX) + startPointX);
            int Y = (int)Math.Floor(((e.Y - Location.Y) / scaleY) + startPointY);

            var path = GameScene.Scene.MapControl.PathFinder.FindPath(MapObject.User.CurrentLocation, new Point(X, Y));

            if (path == null || path.Count == 0)
            {
                GameScene.Scene.ChatDialog.ReceiveChat("Could not find suitable path.", ChatType.System);
            }
            else
            {
                GameScene.Scene.MapControl.CurrentPath = path;
                GameScene.Scene.MapControl.AutoPath    = true;
            }
        }
 public CorePathManager(MapControl mapControl, MapVectorLayer mapVectorLayer)
     : base(mapControl, mapVectorLayer)
 {
 }
Esempio n. 43
0
        private void InitializeMap()
        {
            #region #MapPreparation
            object data = LoadData(xmlFilepath);

            // Create a map and data for it.
            MapControl map = new MapControl()
            {
                CenterPoint       = new GeoPoint(-37.2, 143.2),
                ZoomLevel         = 5,
                Dock              = DockStyle.Fill,
                ToolTipController = new ToolTipController()
                {
                    AllowHtmlText = true
                },
                ImageList = LoadImage(imageFilepath)
            };
            this.Controls.Add(map);
            #endregion #MapPreparation

            map.Layers.Add(new ImageLayer()
            {
                DataProvider = new BingMapDataProvider()
                {
                    BingKey = bingKey
                }
            });
            #region #VectorData
            // Create a vector layer.
            map.Layers.Add(new VectorItemsLayer()
            {
                Data           = CreateAdapter(data),
                ToolTipPattern = "<b>{Name} ({Year})</b> \r\n{Description}",
                ItemImageIndex = 0
            });
            #endregion #VectorData

            #region #MiniMap
            // Create a mini map and data for it.
            MiniMap miniMap = new MiniMap()
            {
                Alignment = MiniMapAlignment.BottomLeft
            };
            miniMap.Layers.Add(new MiniMapImageTilesLayer()
            {
                DataProvider = new BingMapDataProvider()
                {
                    BingKey = bingKey
                }
            });
            miniMap.Layers.Add(new MiniMapVectorItemsLayer()
            {
                Data = CreateMiniMapAdapter(data)
            });
            map.MiniMap = miniMap;
            #endregion #MiniMap

            #region #Legend
            //Create a Legend containing images.
            ColorListLegend legend = new ColorListLegend();
            legend.ImageList = map.ImageList;
            legend.CustomItems.Add(new ColorLegendItem()
            {
                ImageIndex = 0, Text = "Shipwreck"
            });
            map.Legends.Add(legend);
            #endregion #Legend
        }
Esempio n. 44
0
        private async void Search_Click(object sender, RoutedEventArgs e)
        {
            SearchDialog dialog = new SearchDialog(ref dataResult);
            var          result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                if (viewOfRoute != null)
                {
                    mapControl.Routes.Remove(viewOfRoute);
                }

                double a = dataResult.Latitude;


                string address = dataResult.address;

                if (dataResult.fullAddress == true)
                {
                    string addressToGeocode = address;

                    BasicGeoposition queryHint = new BasicGeoposition();
                    queryHint.Latitude  = 47.643;
                    queryHint.Longitude = -122.131;
                    Geopoint hintPoint = new Geopoint(queryHint);

                    MapLocationFinderResult mapResult = await MapLocationFinder.FindLocationsAsync(addressToGeocode, hintPoint, 3);

                    dataResult.Latitude  = mapResult.Locations[0].Point.Position.Latitude;
                    dataResult.Longitude = mapResult.Locations[0].Point.Position.Longitude * -1;


                    // Specify a known location.
                    BasicGeoposition snPosition = new BasicGeoposition {
                        Latitude = mapResult.Locations[0].Point.Position.Latitude, Longitude = mapResult.Locations[0].Point.Position.Longitude
                    };
                    Geopoint snPoint = new Geopoint(snPosition);

                    // Create a XAML border.
                    Border border = new Border
                    {
                        CornerRadius    = new CornerRadius(10),
                        Height          = 100,
                        Width           = 100,
                        BorderBrush     = new SolidColorBrush(Windows.UI.Colors.Orange),
                        BorderThickness = new Thickness(2),
                    };

                    // Center the map over the POI.
                    mapControl.Center    = snPoint;
                    mapControl.ZoomLevel = 14;

                    // Add XAML to the map.
                    mapControl.Children.Add(border);
                    MapControl.SetLocation(border, snPoint);
                    MapControl.SetNormalizedAnchorPoint(border, new Point(0.5, 0.5));
                }
                else
                {
                    var messageDialog = new MessageDialog("Location not found. All fields are required.");
                    await messageDialog.ShowAsync();
                }
            }
        }
Esempio n. 45
0
 private void RotationSliderChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     //var percent = RotationSlider.Value / (RotationSlider.Maximum - RotationSlider.Minimum);
     //MapControl.Navigator.RotateTo(percent * 360);
     MapControl.Refresh();
 }
Esempio n. 46
0
 public MapTool(MapControl mapControl)
 {
     this.mapControl = mapControl;
 }
Esempio n. 47
0
        /// <summary>
        /// 点击地图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void MapTappedAsync(MapControl sender, MapInputEventArgs args)
        {
            if (!IsShowMapCenterFlag)
            {
                return;
            }
            var mapElements = sender.FindMapElementsAtOffset(args.Position);
            var clickItem   = mapElements.FirstOrDefault();

            if (clickItem is MapIcon mapIcon)   //如果点击的是MapIcon
            {
                Map.MapElements.Remove(WalkingPolyLine);

                IsShowDestinationInfo = false;

                if (_lastChangeImgMapIcon != null)  //恢复之前改变为大图标的MapIcon
                {
                    _lastChangeImgMapIcon.Image = _carImageStreamReference;
                    _lastChangeImgMapIcon       = null;
                }

                OriginGeoPosition = Map.Center;
                var origin      = OriginGeoPosition.Position;
                var destination = mapIcon.Location.Position;

                //请求路线
                var walkingRouteResult = await AmapWebApi.GetGetWalkingRouteAsync(origin, destination);

                if (walkingRouteResult?.route?.paths?.FirstOrDefault() is PathsItem walkingPath)    //有行走路径
                {
                    IsShowMapCenterFlag   = false;
                    mapIcon.Image         = _carBigImageStreamReference;
                    _lastChangeImgMapIcon = mapIcon;

                    //创建路径列表,并加入起始点
                    var paths = new List <BasicGeoposition> {
                        origin
                    };

                    foreach (var step in walkingPath.steps) //遍历行走步骤
                    {
                        if (step.PolyLineList != null)
                        {
                            paths.AddRange(step.PolyLineList);
                        }
                    }
                    paths.Add(destination);

                    WalkingPolyLine = new MapPolyline
                    {
                        Path            = new Geopath(paths),
                        StrokeColor     = Color.FromArgb(255, 107, 182, 82),
                        StrokeThickness = 4.5,
                        ZIndex          = 1
                    };

                    Map.MapElements.Add(WalkingPolyLine);

                    //显示行走信息
                    DestinationGeoPosition = mapIcon.Location;
                    WalkingTime            = walkingPath.duration;
                    WalkingDistance        = walkingPath.distance;
                    IsShowDestinationInfo  = true;
                }
            }
        }
Esempio n. 48
0
        public override void OnMouseWheel(ICoordinate mouseWorldPosition, MouseEventArgs e)
        {
            if (Dragging)
            {
                return;
            }

            // zoom map
            double scale = (-e.Delta / 250.0);
            double usedWheelZoomMagnutide = wheelZoomMagnitude;

            // fine zoom if alt is pressed
            if (IsAltPressed)
            {
                usedWheelZoomMagnutide = wheelZoomMagnitude / 8;
            }

            double scaleBase = 1 + usedWheelZoomMagnutide;

            double zoomFactor = scale > 0 ? scaleBase : 1 / scaleBase;

            Map.Zoom *= zoomFactor;

            Rectangle zoomRectangle;

            if (!IsShiftPressed)
            {
                //determine center coordinate in world units
                double newCenterX = mouseWorldPosition.X - Map.PixelWidth * (e.X - MapControl.Width / 2.0);
                double newCenterY = mouseWorldPosition.Y - Map.PixelHeight * (MapControl.Height / 2.0 - e.Y);

                // use current map center if shift is pressed
                Map.Center = new Coordinate(newCenterX, newCenterY);

                // draw zoom rectangle (in screen coordinates)
                zoomRectangle = new Rectangle(
                    (int)(e.X * (1 - zoomFactor)),
                    (int)(e.Y * (1 - zoomFactor)),
                    (int)(MapControl.Size.Width * zoomFactor),
                    (int)(MapControl.Size.Height * zoomFactor));
            }
            else
            {
                // draw zoom rectangle (in screen coordinates)
                zoomRectangle = new Rectangle(
                    (int)(MapControl.Width / 2.0 * (1 - zoomFactor)),
                    (int)(MapControl.Height / 2.0 * (1 - zoomFactor)),
                    (int)(MapControl.Size.Width * zoomFactor),
                    (int)(MapControl.Size.Height * zoomFactor));
            }

            // draw image and clear background in a separate image first to prevent flickering
            using (var previewImage = (Bitmap)Map.Image.Clone())
            {
                using (var g = Graphics.FromImage(previewImage))
                {
                    g.Clear(MapControl.BackColor);
                    g.DrawImage(Map.Image, MapControl.ClientRectangle, zoomRectangle, GraphicsUnit.Pixel);
                    DrawStaticTools(g); // make tools to draw themself while map is being rendered
                }

                // now draw preview image on control
                using (var g = MapControl.CreateGraphics())
                {
                    g.DrawImage(previewImage, 0, 0);
                }
            }

            // call full map rendering (long operation)
            MapControl.Refresh();
        }
Esempio n. 49
0
 public override void useE(Obj_AI_Base target)
 {
     if (E.CanCast(target) && (Q.IsReady() || R.IsReady()))
     {
         if ((MapControl.balanceAroundPoint(player.Position.To2D(), 700) >= -1 || (MapControl.fightIsOn() != null && MapControl.fightIsOn().NetworkId == target.NetworkId)))
         {
             E.Cast(target.ServerPosition);
         }
     }
 }
Esempio n. 50
0
 public MapPaintEventArgs(MapControl control, NamedElement mapElement, MapGraphics graphics)
 {
     this.control    = control;
     this.mapElement = mapElement;
     this.graphics   = graphics;
 }
Esempio n. 51
0
 internal void InvokeElementRemoved(NamedElement sender)
 {
     MapControl.OnElementRemoved(MapControl, new ElementEventArgs(MapControl, sender));
 }
 /// <summary>
 /// Preloads the map.
 /// </summary>
 public static void PreloadMap()
 {
     var h = new MapControl();
 }
Esempio n. 53
0
 public bool safeGap(Obj_AI_Base target)
 {
     return(MapControl.safeGap(target));
 }
Esempio n. 54
0
 private void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     MapFunctions.RaiseMapClicked(args.Location.ToPosition());
 }
 internal ShapefileMapper(VectorLayerMapper vectorLayerMapper, Dictionary <SpatialElementKey, SpatialElementInfoGroup> spatialElementsDictionary, MapControl coreMap, MapMapper mapMapper)
     : base(vectorLayerMapper, spatialElementsDictionary, coreMap, mapMapper)
 {
     m_shapefile = (MapShapefile)m_mapVectorLayer.MapSpatialData;
 }
Esempio n. 56
0
 private void Map_MapHolding(MapControl sender, MapInputEventArgs args)
 {
     MapFunctions.RaiseMapLongPress(args.Location.ToPosition());
 }
Esempio n. 57
0
 public GpsVM(MapControl mapa)
 {
     Mapa = mapa;
     GetUserLocationData = new RelayCommand(getLocationData);
 }
Esempio n. 58
0
 private void MyMap_OnMapElementClick(MapControl sender, MapElementClickEventArgs args)
 {
     mapController.OnMapElementCLick(sender, args, buildingsVistiting);
 }
Esempio n. 59
0
        public void SetUsers()
        {
            if (!App.ViewModel.IsMapVisible)
            {
                return;
            }

            // clean up
            if (MapControl.Layers.Count == 0)
            {
                MapControl.Layers.Add(new MapLayer());
            }
            var layer = MapControl.Layers.First();

            layer.Clear();

            //set me
            var me = App.ViewModel.Coordinate;

            if (me != null)
            {
                var myColor = ConvertHtmlColor("#123123");
                layer.Add(new MapOverlay
                {
                    GeoCoordinate = new GeoCoordinate(me.Lat, me.Lon),
                    Content       = new GeoUser
                    {
                        Name   = "Me",
                        Speed  = me.SpeedKmh.ToString("N0"),
                        Fill   = new SolidColorBrush(myColor),
                        Stroke = new SolidColorBrush(MakeDarker(myColor)),
                        U      = "-1",
                    },
                    ContentTemplate = this.Resources["MeTemplate"] as DataTemplate,
                });
            }

            // set others
            if (App.ViewModel.GroupsModel.Tracks != null)
            {
                foreach (var user in App.ViewModel.GroupsModel.Tracks)
                {
                    var groupUser = App.ViewModel.GroupsModel.Groups.Where(w => w.Active).SelectMany(s => s.Users).FirstOrDefault(f => f.U == user.Key);
                    if (groupUser == null)
                    {
                        continue;
                    }
                    var coordinate    = user.Value[user.Value.Count - 1];
                    var geoCoordinate = new GeoCoordinate(coordinate.Lat, coordinate.Lon);
                    var point         = MapControl.ConvertGeoCoordinateToViewportPoint(geoCoordinate);
                    if (point.X < -100 || point.X > MapControl.RenderSize.Width + 100 || point.Y < -100 || point.Y > MapControl.RenderSize.Height + 100)
                    {
                        continue;
                    }
                    var color = ConvertHtmlColor(groupUser.Color);
                    layer.Add(new MapOverlay
                    {
                        GeoCoordinate = geoCoordinate,
                        Content       = new GeoUser
                        {
                            Name   = groupUser.Name,
                            Speed  = coordinate.SpeedKmh.ToString("N0"),
                            Fill   = new SolidColorBrush(color),
                            Stroke = new SolidColorBrush(MakeDarker(color)),
                            U      = user.Key,
                        },
                        ContentTemplate = this.Resources["UserTemplate"] as DataTemplate
                    });
                }
                ;
            }

            if (LockedUser != null)
            {
                var user = layer.FirstOrDefault(f => (f.Content as GeoUser).U == LockedUser);
                if (user != null)
                {
                    var xcenter  = MapControl.RenderSize.Width / 2;
                    var ycenter  = MapControl.RenderSize.Height / 2;
                    var point    = MapControl.ConvertGeoCoordinateToViewportPoint(user.GeoCoordinate);
                    var distance = Math.Sqrt(Math.Pow(xcenter - point.X, 2) + Math.Pow(ycenter - point.Y, 2));
                    if (distance > 50)
                    {
                        MapControl.Center = user.GeoCoordinate;
                    }
                }
            }
        }
Esempio n. 60
0
 public static MapControl ConvertMapControl(int i)
 {
     return(MapControl.GetMapControl(i));
 }