private void MapWithPushpins_MouseDoubleClick(object sender, MouseButtonEventArgs e) { // Disables the default mouse double-click action. e.Handled = true; // Determin the location to place the pushpin at on the map. //Get the mouse click coordinates Point mousePosition = e.GetPosition(this); //Convert the mouse coordinates to a locatoin on the map Location pinLocation = myMap.ViewportPointToLocation(mousePosition); setPoints(pinLocation); return; // The pushpin to add to the map. Pushpin pin = new DraggablePin(myMap); // pin. pin.Location = pinLocation; pin.Content = cnt++; pin.ToolTip = pinLocation.ToString(); pin.MouseRightButtonDown += new MouseButtonEventHandler(pin_MouseDown); // Adds the pushpin to the map. myMap.Children.Add(pin); }
private void MyMap_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (e.Handled) { return; } // Disables the default mouse double-click action. e.Handled = true; // Determin the location to place the pushpin at on the map. //Get the mouse double click coordinates Point mousePosition = e.GetPosition(MyMap); //Convert the mouse coordinates to a locatoin on the map Location pinLocation = MyMap.ViewportPointToLocation(mousePosition); // The pushpin to add to the map. DraggablePin pin = new DraggablePin(MyMap, DraggablePinDroppedHanlder); pin.Location = pinLocation; // Adds the pushpin to the map. MyMap.Children.Add(pin); //Update the current latitude and longitude lat = pinLocation.Latitude; lng = pinLocation.Longitude; tbLocation.Text = Global.getAddress(lat, lng); string weather = Global.getWeather(lat, lng); ToolTipService.SetToolTip(pin, weather); }
private void DirectionsMainUserControl_Loaded(object sender, RoutedEventArgs e) { DraggablePin pin = new DraggablePin(MapView.MapControl, this); pin.Name = "OrDesSelector"; MapControl.SetLocation(pin, MapView.MapControl.Center); //Set the pin as draggable. pin.Draggable = true; //Add the pin to the map. MapView.MapControl.Children.Add(pin); }
private void DirectionsMainUserControl_Loaded(object sender, RoutedEventArgs e) { //var pin = (MapIcon)await TestPin.Run(MapView.MapControl); var pin = new DraggablePin(MapView.MapControl, this); pin.Name = "OrDesSelector"; MapControl.SetLocation(pin, MapView.MapControl.Center); //Set the pin as draggable. pin.Draggable = true; //Add the pin to the map. MapView.MapControl.Children.Add(pin); //MapView.MapControl.CenterChanged += MapControl_CenterChanged; }
void PinDraggable(Transform tran) { float pin_distance = 30; int cur_day = Singleton <SceneManager> .Instance.m_cur_day; float dist = Vector3.Distance(tran.position, m_days_list[cur_day].position); DraggablePin pin = tran.GetComponent <DraggablePin>(); if (dist < pin_distance) { CalenderModel.SetDayPin(cur_day, pin.idx); tran.position = m_days_list[cur_day].position; tran.localEulerAngles = new Vector3(0, 0, 0); } else { pin.ReturnOrigionRotation(); } }
public void refreshPushpins() { MyMap.Children.Clear(); List <Stop> stopList = Global.Db.GetAllStops(userId); TraceRoot(stopList); foreach (Stop stop in stopList) { double lat = stop.Lat; double lng = stop.Lng; var pin = new DraggablePin(MyMap, DraggablePinDroppedHanlder, stop); pin.Location = new Location(lat, lng); MyMap.Children.Add(pin); string weather = Global.getWeather(lat, lng); ToolTipService.SetToolTip(pin, weather); } }
/// <summary> /// Double-click to add a marker to the map to build a route /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void MainMap_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { // Disables the default mouse double-click action. e.Handled = true; //Get the mouse click coordinates Point mousePosition = e.GetPosition(MainMap); //Convert the mouse coordinates to a locatoin on the map Location pinLocation = MainMap.ViewportPointToLocation(mousePosition); // The pushpin to add to the map. DraggablePin pin = new DraggablePin(MainMap) { Background = new SolidColorBrush(Color.FromRgb(58, 74, 216)), Foreground = new SolidColorBrush(Colors.White), Location = pinLocation, Content = OsrmWayPointsPushpins.Count + 1 }; if (_wayPointsEditModeEnabled && WayPointsForOsrmDataGrid.SelectedIndex >= 0) { OsrmWayPointsPushpins.Insert(WayPointsForOsrmDataGrid.SelectedIndex + 1, pin); SetPushinsEnumaration(OsrmWayPointsPushpins); WayPointsForOsrmDataGrid.SelectRowByIndex(WayPointsForOsrmDataGrid.SelectedIndex + 1); } else { OsrmWayPointsPushpins.Add(pin); } pin.MouseDown += Pin_MouseDown; MainMap.Children.Add(pin); if (AutoRouteDrowCheckBox.IsChecked != null && AutoRouteDrowCheckBox.IsChecked == true) { await GetLoadOsrmTrack(); } CheckTabItems(); }
void placePin(double p1, double p2, int index = -1) { Pushpin pin = new DraggablePin(myMap); pin.Location = new Location(p1, p2); if (index < 0) { pin.Content = cnt++; } else { pin.Content = index; } pin.ToolTip = p1.ToString() + ":" + p2.ToString(); // Adds the pushpin to the map. myMap.Children.Add(pin); // myMap.Center = pin.Location; pin.MouseRightButtonDown += new MouseButtonEventHandler(pin_MouseDown); }
public void DraggablePinDroppedHanlder(DraggablePin pin) { if (pin._stop != null) { var pinLocation = pin.Location; int currentStopId = Global.Db.SelectStopId(pin._stop.Lat, pin._stop.Lng); lat = pinLocation.Latitude; lng = pinLocation.Longitude; string address = Global.getAddress(lat, lng); tbLocation.Text = address; Global.Db.UpdateStop(currentStopId, lat, lng, address); refreshPushpins(); refreshStops(); } else { var pinLocation = pin.Location; lat = pinLocation.Latitude; lng = pinLocation.Longitude; string address = Global.getAddress(lat, lng); tbLocation.Text = address; } }
// This constructor initializes the Map and currentMarker public MainMap() { InitializeComponent(); map.Focus(); ///this part was in the demo, but I found that removing this part ///does not affect the functionality of the map #region demo part //try //{ // Random rnd = new Random(); // int port = rnd.Next(8800, 8900); // GMapProvider.WebProxy = new WebProxy("127.0.0.1", 1080); // GMapProvider.IsSocksProxy = true; // GMaps.Instance.EnableTileHost(port); //} //catch (Exception ex) //{ // Debug.WriteLine("ex: " + ex); //} #endregion // Initialize currentMarker to be at IIS currentMarker = new DraggablePin(map); { currentMarker.Location = new Location(25.04133, 121.6133); currentMarker.ToolTip = new Label() { Content = "Current Position" }; } currentMarker.Background = new SolidColorBrush(Color.FromArgb(100, 100, 100, 100)); map.Children.Add(currentMarker); //initialize the satellite map stalliteMap.MapProvider = GMap.NET.MapProviders.BingSatelliteMapProvider.Instance; stalliteMap.Position = new PointLatLng(23.6978, 120.9605); stalliteMap.Zoom = 13; stalliteMap.CanDragMap = false; }
// return currentMarker for other class to manipulate public DraggablePin GetCurrentMarker() { if (currentMarker == null) { currentMarker = new DraggablePin(map); } return currentMarker; }
// add draggable pushpin to the map public void AddDraggablePins(Location loc, string label) { var pin = new DraggablePin(map); { pin.Location = new Location(loc); pin.ToolTip = new Label() { Content = label }; } map.Children.Add(pin); }