private async void MoveMapToCurrentPositionAsync() { bool isLocationPermision = await CheckLocationPermisionsAsync(); if (isLocationPermision) { MyMap.IsShowingUser = true; await _geolocatorService.GetLocationAsync(); if (_geolocatorService.Latitude != 0 && _geolocatorService.Longitude != 0) { Position position = new Position( _geolocatorService.Latitude, _geolocatorService.Longitude); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius( position, Distance.FromKilometers(.5))); } } }
private async void FindRouteTextBox_KeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { if (StartPositionTextBox.Text != string.Empty && EndPositionTextBox.Text != string.Empty) { var startPlace = findPlace(StartPositionTextBox.Text).First(); var endPlace = findPlace(EndPositionTextBox.Text).First(); if (startPlace == null || endPlace == null) { await giveMessageAsync("未能在校内找到起点或终点"); } else { StartPositionTextBox.Text = startPlace.Name; EndPositionTextBox.Text = endPlace.Name; var routeResult = await MapRouteFinder.GetWalkingRouteAsync(startPlace.Position, endPlace.Position); try { DrawRoute(routeResult.Route); MyMap.ZoomLevel = 18; await MyMap.TrySetViewAsync(startPlace.Position, MyMap.ZoomLevel, MyMap.Heading, MyMap.Pitch, MapAnimationKind.Linear); FindRouteFlyout.Hide(); } catch (Exception) { await giveMessageAsync("抱歉,未能找到路线,试试自带地图吧。"); } } } else { await giveMessageAsync("请输入起点、终点(仅限校内地点)"); } } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; try { // Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); // _accuracy = currentPosition.Coordinate.Accuracy; Dispatcher.BeginInvoke(() => { MyCoordinate = new GeoCoordinate(36.115381, -115.198145); //hard coded the location of Palms casino in Vegas (venue) MyMap.Layers.Clear(); //On one layer draw store locations MapLayer layer = new MapLayer(); foreach (PointOfInterest p in locations) { DrawMapMarker(p.coord, Colors.Red, layer); } MyMap.Layers.Add(layer); //On next layer draw my location MapLayer currLocLayer = new MapLayer(); DrawMapMarker(MyCoordinate, Colors.Blue, currLocLayer); MyMap.Layers.Add(currLocLayer); //Animate into view MyMap.SetView(MyCoordinate, 13, MapAnimationKind.Linear); }); } catch (Exception) { Debug.WriteLine("Problem setting current position in Map"); } }
private void UpdateMap() { try { var assembly = IntrospectionExtensions.GetTypeInfo(typeof(AboutPage)).Assembly; Stream stream = assembly.GetManifestResourceStream("BankerPro.Places.json"); string text = string.Empty; using (var reader = new StreamReader(stream)) { text = reader.ReadToEnd(); } var resultObject = JsonConvert.DeserializeObject <Places>(text); string json = JsonConvert.SerializeObject(resultObject); foreach (var place in resultObject.results) { placesList.Add(new Place { PlaceName = place.name, Address = place.vicinity, Location = place.geometry.location, Position = new Position(place.geometry.location.lat, place.geometry.location.lng), //Icon = place.icon, //Distance = $"{GetDistance(lat1, lon1, place.geometry.location.lat, place.geometry.location.lng, DistanceUnit.Kiliometers).ToString("N2")}km", //OpenNow = GetOpenHours(place?.opening_hours?.open_now) }); } MyMap.ItemsSource = placesList; //PlacesListView.ItemsSource = placesList; //var loc = await Xamarin.Essentials.Geolocation.GetLocationAsync(); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(47.6370891183, -122.123736172), Distance.FromKilometers(100))); } catch (Exception ex) { Debug.WriteLine(ex); } }
/// <summary> /// Locate myself, show the marker and upload my location /// </summary> /// <returns></returns> public async System.Threading.Tasks.Task LocateMe() { try { Geoposition position = await myGeoLocator.GetGeopositionAsync(maximumAge : TimeSpan.FromMinutes(1), timeout : TimeSpan.FromSeconds(30)); GPSLocationTextblock.Text = "Location: " + string.Format("Lat: {0:0.0000}, Long: {1:0.0000}, Acc: {2}m", position.Coordinate.Latitude, position.Coordinate.Longitude, position.Coordinate.Accuracy); Me.Latitude = position.Coordinate.Latitude; Me.Longitude = position.Coordinate.Longitude; } catch (UnauthorizedAccessException) { GPSLocationTextblock.Text = "Location is disabled in phone settings."; } catch (Exception ex) { GPSLocationTextblock.Text = ex.Message; } finally { if (Me.isLocated()) { if (App.ViewModel.IsDataLoaded) //to ensure Me.uid has been set { try { //proxy.setLocationCompleted += proxy_setLocationCompleted; proxy.setLocationAsync(Me.Uid, Me.Latitude, Me.Longitude); } catch (TimeoutException e) { MessageBox.Show(e.Message); } } MyLocationMarker.Visibility = System.Windows.Visibility.Visible; MyMap.SetView(new GeoCoordinate(Me.Latitude, Me.Longitude), MyMap.ZoomLevel, MapAnimationKind.Parabolic); } } }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = NavigationParameter as CoffeeMapViewModel; if (vm == null) { return; } Record record = vm.Record; if (record == null) { return; } if (record.geometry == null || record.geometry.coordinates == null) { return; } try { var recordCoordinates = record.geometry.coordinates; var latitude = recordCoordinates[1]; var longitude = recordCoordinates[0]; var coords = new CLLocationCoordinate2D(latitude, longitude); SetMapToCoordinate(coords); Title = record.fields.nom_du_cafe; var pin = new BasicPinAnnotation(coords, record.fields.nom_du_cafe, record.fields.adresse); MyMap.AddAnnotation(pin); } catch (Exception) { } }
private async void CancelSignIn_ClickedAsync(object sender, EventArgs e) { var updated = Controller.InstanceCreation().clearGPSData("calendar.event", "app_cancel_sign_in", editobj.id); MyMap.MoveToRegion( MapSpan.FromCenterAndRadius( new Position(0, 0), Distance.FromMiles(0.05))); var position1 = new Position(0, 0); var pin1 = new Pin { Type = PinType.Place, Position = position1, Label = "Your Address", Address = "", }; MyMap.Pins.Add(pin1); var currentpage = new LoadingAlert(); await PopupNavigation.PushAsync(currentpage); await DisplayAlert("Alert", "Location Successfully Updated", "Ok"); // App.Current.MainPage = new MasterPage(new CalendarPage()); await PopupNavigation.PopAsync(); // Loadingalertcall(); sign_time.Text = ""; signin_loc.IsVisible = true; cancel_signin.IsVisible = false; // await RetrieveLocationForSignOut(); }
private void QueryCompleted(object sender, QueryCompletedEventArgs <Route> e) { if (e.Error == null) { try { Route MyRoute = e.Result; MyMapRoute = new MapRoute(MyRoute); MyMapRoute.Color = CurrentColor; MyMap.AddRoute(MyMapRoute); Route.Text = ""; List <string> RouteList = new List <string>(); foreach (RouteLeg leg in MyRoute.Legs) { foreach (RouteManeuver maneuver in leg.Maneuvers) { RouteList.Add(maneuver.InstructionText); } } foreach (string line in RouteList) { Route.Text += dot + ". " + line + '\n'; dot++; } calculate.Text = "Find cycle"; calculate.IconUri = new Uri("/Images/dark.shuffle.png", UriKind.Relative); start.Text = "Find path"; start.IconUri = new Uri("/Images/dark.map.treasure.png", UriKind.Relative); EnableAppButtons(true); MyQuery.Dispose(); } catch (InvalidOperationException ex) { } } }
/// <summary> /// OnAppearingメソッド(Pageが表示される直前) /// 参考サイト:https://shuhelohelo.hatenablog.com/entry/2020/01/02/031311 /// </summary> protected override void OnAppearing() { base.OnAppearing(); try { //高知駅へ移動させる MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Xamarin.Forms.GoogleMaps.Position(33.5684, 133.5566), Distance.FromKilometers(10))); //ピンを立てる var pin = new Pin() { Type = PinType.Place, Label = "ピンを追加テスト", Address = "Hello Tokyo", Position = new Xamarin.Forms.GoogleMaps.Position(35.6762, 139.6503), //東京 Rotation = 0, // -33.3f などとするとピンを傾けることができる Tag = "", IsDraggable = true, //これだけでピンを長押しすると移動モードになる }; //マップへ追加 MyMap.Pins.Add(pin); //var pin2 = new Pin() //{ // Type = PinType.Place, // Label = "高知駅", // Address = "Hello Kochi", // Position = new Xamarin.Forms.GoogleMaps.Position(33.5658, 133.5437), //高知駅 // Rotation = 0, // Tag = "", // IsDraggable = true, //}; //MyMap.Pins.Add(pin2); } catch (Exception ex) { Debug.WriteLine(ex); } }
private async void UpdateMap() { try { var assembly = IntrospectionExtensions.GetTypeInfo(typeof(DealerMap)).Assembly; Stream stream = assembly.GetManifestResourceStream("MobileHelper.DealerPlaces.json"); string text = string.Empty; using (var reader = new StreamReader(stream)) { text = reader.ReadToEnd(); } var resultObject = JsonConvert.DeserializeObject <DealerPlaces>(text); foreach (var place in resultObject.results) { //byte[] conv = Encoding.Default.GetBytes(place.name); //place.name = Encoding.UTF8.GetString(conv); placesList.Add(new DealerPlace { PlaceName = place.name, Address = place.vicinity, Location = place.geometry.location, Position = new Position(place.geometry.location.lat, place.geometry.location.lng), //Icon = place.icon, //Distance = $"{GetDistance(lat1, lon1, place.geometry.location.lat, place.geometry.location.lng, DistanceUnit.Kiliometers).ToString("N2")}km", //OpenNow = GetOpenHours(place?.opening_hours?.open_now) });; } MyMap.ItemsSource = placesList; //PlacesListView.ItemsSource = placesList; //var loc = await Xamarin.Essentials.Geolocation.GetLocationAsync(); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(53.127068, 29.194726), Distance.FromKilometers(100))); } catch (Exception ex) { Debug.WriteLine(ex); } }
public void TestRemoveObject() { Object key = new Object(); Object val = new Object(); AbstractMap <Object, Object> map1 = new HashMap <Object, Object>(0); map1.Put("key", val); Assert.AreSame(map1.Remove("key"), val, "HashMap(0)"); AbstractMap <Object, Object> map5 = new LinkedHashMap <Object, Object>(122); map5.Put(key, val); Assert.AreSame(map5.Remove(key), val, "LinkedHashMap"); AbstractMap <Object, Object> aSpecialMap = new MyMap(); aSpecialMap.Put(specialKey, specialValue); Object valueOut = aSpecialMap.Remove(specialKey); Assert.AreSame(valueOut, specialValue, "MyMap"); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { // Replace MAP_SERVICE_TOKEN with token from bing maps dev center MyMap.MapServiceToken = "MAP_SERVICE_TOKEN"; // Use the device's Geolocator to find it's physical location Geopoint myPoint; if (e.Parameter == null) { // Add isViewing = false; var locator = new Geolocator(); locator.DesiredAccuracyInMeters = 50; /* Add Location capability in the Package.appxmanifest file */ var position = await locator.GetGeopositionAsync(); myPoint = position.Coordinate.Point; } else { // View or Delete isViewing = true; mapNote = (MapNote)e.Parameter; titleTextBox.Text = mapNote.Title; noteTextBox.Text = mapNote.Note; addButton.Content = "Delete"; var myPosition = new BasicGeoposition(); myPosition.Latitude = mapNote.Latitude; myPosition.Longitude = mapNote.Longitude; myPoint = new Geopoint(myPosition); } await MyMap.TrySetViewAsync(myPoint, 10D); }
private async void Locator() { try { var locator = CrossGeolocator.Current; if (locator.IsGeolocationAvailable && locator.IsGeolocationEnabled) { locator.DesiredAccuracy = 50; //var location = await locator.GetPositionAsync(timeoutMilliseconds: 10000); var location = await locator.GetPositionAsync(); var position = new Position(location.Latitude, location.Longitude); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromMiles(.3))); } } catch (Exception ex) { ex.ToString(); } }
private void PanClick(object sender, RoutedEventArgs e) { Envelope extent = MyMap.Extent; if (extent == null) { return; } MapPoint center = extent.GetCenter(); switch ((sender as Button).Tag.ToString()) { case "W": MyMap.PanTo(new MapPoint(extent.XMin, center.Y)); break; case "E": MyMap.PanTo(new MapPoint(extent.XMax, center.Y)); break; case "N": MyMap.PanTo(new MapPoint(center.X, extent.YMax)); break; case "S": MyMap.PanTo(new MapPoint(center.X, extent.YMin)); break; case "NE": MyMap.PanTo(new MapPoint(extent.XMax, extent.YMax)); break; case "SE": MyMap.PanTo(new MapPoint(extent.XMax, extent.YMin)); break; case "SW": MyMap.PanTo(new MapPoint(extent.XMin, extent.YMin)); break; case "NW": MyMap.PanTo(new MapPoint(extent.XMin, extent.YMax)); break; default: break; } }
/// <summary> /// Event handler for geocode query completed. /// </summary> /// <param name="e">Results of the geocode query - list of locations</param> private void GeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e) { HideProgressIndicator(); if (e.Error == null) { if (e.Result.Count > 0) { if (_isRouteSearch) // Query is made to locate the destination of a route { // Only store the destination for drawing the map markers MyCoordinates.Add(e.Result[0].GeoCoordinate); // Route from current location to first search result List <GeoCoordinate> routeCoordinates = new List <GeoCoordinate>(); routeCoordinates.Add(MyCoordinate); routeCoordinates.Add(e.Result[0].GeoCoordinate); CalculateRoute(routeCoordinates); } else // Query is made to search the map for a keyword { // Add all results to MyCoordinates for drawing the map markers. for (int i = 0; i < e.Result.Count; i++) { MyCoordinates.Add(e.Result[i].GeoCoordinate); } // Center on the first result. MyMap.SetView(e.Result[0].GeoCoordinate, 10, MapAnimationKind.Parabolic); } } else { MessageBox.Show(AppResources.NoMatchFoundMessageBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK); } MyGeocodeQuery.Dispose(); } DrawMapMarkers(); }
private async void btnGetLocation_Clicked(object sender, EventArgs e) { ILocation loc = DependencyService.Get <ILocation>(); loc.locationObtained += LocationObtained; loc.ObtainMyLocation(); loc = null; //await Task.Delay(4000); Position position = new Position(lat, lng); Pin pin = new Pin { Type = PinType.Place, Position = position, Label = "My Pin", }; MyMap.Pins.Add(pin); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lng), Distance.FromMeters(1000))); }
private void MostrarMapa() { int pros = 0; pros += 1; if (ingUbicacion.Text != "Ingrese ubicación") { if (ingUbicacion != null) { Localizar(); } else { Gps(); } } // if(ingUbicacion.Text!=null) // if(ingUbicacion.Text != "") MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(latitud, longitud), Distance.FromKilometers(1))); Console.WriteLine(pros); }
public async void Load_Info() { try { UserDialogs.Instance.ShowLoading("Loading..."); var UserTable = App.MobileService.GetTable <Info>(); var result = await UserTable.Where(x => x.First != string.Empty).ToListAsync(); var Name = result.FirstOrDefault(); First1.Text = Name.First; Last1.Text = Name.Last; Telephone1.Text = Name.Telephone; Date1.Text = Name.Date; Time1.Text = Name.Time; double Lat = Convert.ToDouble(Name.Lat); double Long = Convert.ToDouble(Name.Long); var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 20; var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(10000)); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(Lat, Long), Distance.FromMiles(1))); var pos = new Position(Lat, Long); // Latitude, Longitude var pin = new Pin { Type = PinType.Place, Position = pos, Label = "custom pin", Address = "custom detail info" }; MyMap.Pins.Add(pin); UserDialogs.Instance.HideLoading(); } catch (Exception x) { } }
private async void MyMap_Loaded(object sender, RoutedEventArgs e) { if (MyMap.Is3DSupported) { MyMap.Style = MapStyle.Aerial3DWithRoads; MyMap.StyleSheet = MapStyleSheet.RoadDark(); BasicGeoposition geoPosition = new BasicGeoposition(); geoPosition.Latitude = 41.790366; geoPosition.Longitude = -6.760116; Geopoint myPoint = new Geopoint(geoPosition); MyMap.Center = myPoint; MyMap.ZoomLevel = 10; MapScene hwScene = MapScene.CreateFromLocationAndRadius(myPoint, 80, 0, 60); await MyMap.TrySetSceneAsync(hwScene, MapAnimationKind.Bow); MapScene mapScene = MapScene.CreateFromLocationAndRadius(new Geopoint(geoPosition), 500, 150, 70); await MyMap.TrySetSceneAsync(mapScene); } }
/// <summary> /// Event handler for search input text box key down. /// </summary> private void SearchTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (SearchTextBox.Text.Length > 0) { // New query - Clear the map of markers and routes if (MyMapRoute != null) { MyMap.RemoveRoute(MyMapRoute); } MyCoordinates.Clear(); DrawMapMarkers(); HideDirections(); AppBarDirectionsMenuItem.IsEnabled = false; SearchForTerm(SearchTextBox.Text); this.Focus(); } } }
async Task LoadSafePin() { var locationVM = LocationViewModel.GetInstance(); await locationVM.LoadSafePin(); var pin = locationVM.CreatorPin; locationVM.Locationtxt = ""; var location = locationVM.Loc; var position = new Position(location.Latitude, location.Longitude); MyMap.Pins[0].Position = position; if (MovePinAllowed) { MovePinAllowed = false; } //move Screen MyMap.MoveToRegion(MapSpan.FromCenterAndRadius( new Position(location.Latitude, location.Longitude), Distance.FromMiles(3))); }
async Task ShowMap(Address address) { var geocoder = new Geocoder(); try { var positions = await geocoder.GetPositionsForAddressAsync(address.Street + "" + address.City); Debug.WriteLine(positions.Count()); if (positions.Count() > 0) { var pos = positions.First(); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(pos, Distance.FromMeters(5000))); } } catch (Exception) { await DisplayAlert("Suche nach Addresse", "Adresse wurde nicht gefunden", "OK"); } }
private void UpdateMapAsync() { try { var pinCineplex = new Pin() { Position = new Position(51.9519062, 7.6321126), Label = "CINEPLEX Münster", Address = "30.09 ist der Bürgersteig bis 12.00 Uhr geschlossen.", }; var pinKindergarten = new Pin() { Position = new Position(51.97004, 7.6333313), Label = "Kindergarten \"Regenbogen\"", Address = "Belastung von Eichenprozessionsspinner.", }; var pinBahnhof = new Pin() { Position = new Position(51.9625937, 7.5202854), Label = "Münster Hauptbahnhof", Address = "Der Hauptbahnhof ist wieder EPS frei.", }; var pinAral = new Pin() { Position = new Position(51.9540987, 7.6399258), Label = "Aral", Address = "Funktioniert wieder .", }; MyMap.Pins.Add(pinCineplex); MyMap.Pins.Add(pinKindergarten); MyMap.Pins.Add(pinBahnhof); MyMap.Pins.Add(pinAral); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(51.9502139, 7.4840153), Distance.FromKilometers(100))); } catch (Exception ex) { Debug.WriteLine(ex); } }
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Map> e) { base.OnElementChanged(e); if (e.OldElement == null) { mapView = Control as MapView; map = mapView.Map; myMap = e.NewElement as MyMap; PolylineOptions line = new PolylineOptions(); line.InvokeColor(global::Android.Graphics.Color.Red); // Add the points of the polyline LatLng latLng = new LatLng(37, -122); line.Add(latLng); //latLng = new LatLng(37, -122.001); //line.Add(latLng); latLng = new LatLng(37.001, -122.002); line.Add(latLng); // Add the polyline to the map map.AddPolyline(line); } }
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e) { _graphicLocation.Geometry = mercator.FromGeographic(new MapPoint(e.Position.Location.Longitude, e.Position.Location.Latitude)); // Use horizontal accuracy (returned in meters) to zoom to the location if (initialLoad) { Envelope rect = new Envelope( (_graphicLocation.Geometry as MapPoint).X - (e.Position.Location.HorizontalAccuracy / 2), (_graphicLocation.Geometry as MapPoint).Y - (e.Position.Location.HorizontalAccuracy / 2), (_graphicLocation.Geometry as MapPoint).X + (e.Position.Location.HorizontalAccuracy / 2), (_graphicLocation.Geometry as MapPoint).Y + (e.Position.Location.HorizontalAccuracy / 2)); MyMap.ZoomTo(rect.Expand(20)); initialLoad = false; } else { MyMap.PanTo(_graphicLocation.Geometry); } }
private void Pushpin_OnDragStarted(object sender, DragStartedGestureEventArgs e) { MyMap.IsEnabled = false; // prevents the map from dragging w/ pushpin} #region 更前のコード /* * Pushpin draggingPin = sender as Pushpin; * * //MessageBox.Show(draggingPin.Parent.ToString()); * * Point p = MyMap.LocationToViewportPoint(draggingPin.Location); * PushPin_Point.X = p.X; * PushPin_Point.Y = p.Y; * * var pins = from pin in PushPinViewModel.PushPins * where pin.Location == (sender as Pushpin).Location * select pin; * if (pins.Count() != 0) * { * pin = pins.First(); * } */ #endregion //これをnewしておくと、ピンがかさなっていても一緒に動かない。 //ただし、移動量は相変わらず重なっているピンの数に比例して2倍、3倍となる。 PushPin_Point = new Point(); PushPin_GeoCoordinate = new GeoCoordinate(); DraggingPin = new PushPinModel(); DraggingPin = (sender as Pushpin).DataContext as PushPinModel; //DraggingPin.Selected = true; PinName = DraggingPin.Name; Point p = MyMap.LocationToViewportPoint(DraggingPin.Location); PushPin_Point.X = p.X + 80; PushPin_Point.Y = p.Y - 120; }
private void geoCode_DownloadReverseGeoCodeResultCompleted(object sender, DownloadGeoCodeResultCompletedEventArgs e) { if (e.Status != "Completed") { return; } var xmlDoc = XElement.Parse(e.Result); var ns = xmlDoc.Name.Namespace; var locations = from location in xmlDoc.Descendants(ns + "location") select location; if (locations.Count() == 0) { return; } var firstElement = locations.First(); //string[] geocoordinate = ((string)firstElement.Element(ns + "Point").Element(ns + "coordinates").Value).Split(','); string[] geocoordinate = new string[] { firstElement.Element(ns + "lat").Value, firstElement.Element(ns + "lng").Value }; var searchLocation = new GeoCoordinate(Convert.ToDouble(geocoordinate[0]), Convert.ToDouble(geocoordinate[1])); PushPinView.ClearSelected(); //候補地ピンの座標を設定 candidatePin.Location = searchLocation; MyMap.SetView(candidatePin.Location, MyMap.ZoomLevel); if (MyMap.Children.Contains(candidatePin) == false) { MyMap.Children.Add(candidatePin); } }
private async void ShowTrapsOnMap(List <System.Windows.Point> pixels) { if (pixels != null && pixels.Count > 0 && imagePosition != null && imagePosition.Count > 0) { var pins = new List <GeoPoint>(); var topLeftPixel = await MyMap.PositionToPixel(imagePosition[0]); //Calculate approximate pixel coordinates. Since images cover small areas we can use linear approximations. var imageWidth = img.Width; var imageHeight = img.Height; var west = imagePosition[0].Longitude; var dLng = imagePosition[2].Longitude - west; var north = imagePosition[0].Latitude; var dLat = north - imagePosition[2].Latitude; if (topLeftPixel != null && topLeftPixel.HasValue) { foreach (var p in pixels) { pins.Add(new GeoPoint(new Position(west + (p.X / imageWidth) * dLng, north - (p.Y / imageHeight) * dLat))); } trapLayer = new SymbolLayer() { Source = new GeoJsonSource(), Options = new SymbolOptions { IconImage = "pin-round-red" } }; (trapLayer.Source as GeoJsonSource).AddRange(pins); MyMap.Layers.Add(trapLayer); } } }
public mh2vecka10onsPage() { InitializeComponent(); // AIzaSyBVfcFZ3M52FBlp2eX-ABEdNHo8sIWWumo MyMap.MapType = MapType.Hybrid; MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(56.037959, 12.698178), Distance.FromMeters(1000))); /* * var pin = new Pin * { * Type = PinType.Place, * Position = new Position(56.037959, 12.698178), * Label = "custom pin", * Address = "custom detail info" * }; * MyMap.Pins.Add(pin); * * var pin2 = new Pin * { * Type = PinType.Place, * Position = new Position(56.039014, 12.698505), * Label = "Campus", * Address = "Ingång" * }; * pin2.Clicked += async (sender, e) => { * System.Diagnostics.Debug.WriteLine("KLICKA PÅ PINNE!!"); * }; * * MyMap.Pins.Add(pin2); */ makePin(56.037959, 12.698178, "Pinne 1"); makePin(56.038959, 12.697478, "Pinne 2"); makePin(56.038559, 12.697978, "Pinne 3"); makePin(56.039259, 12.698378, "Pinne 4"); makePin(56.039759, 12.698278, "Pinne 5"); }
void CreateMap() { /* Map currentMap = new Map * { * HasScrollEnabled = true, * HasZoomEnabled = true, * MapType = MapType.Street * * }; * * Pin pin = new Pin * { * Type =PinType.Place, * Address = "Anıtkabir", * Label = "AnıtkabirLabel", * Position = new Position(39.925, 32.836944) * * }; * currentMap.Pins.Add(pin); * * * currentMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(39.925, 32.836944), Distance.FromKilometers(10))); * Content = currentMap; */ /* * Pin pin = new Pin * { * Type = PinType.Place, * Address = "Anıtkabir", * Label = "AnıtkabirLabel", * Position = new Position(39.925, 32.836944) * * }; * */ MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(39.925, 32.836944), Distance.FromKilometers(10))); // MyMap.Pins.Add(pin); }
public static void Main() { MyMap map = new MyMap(); map.Add(-1,1); map.Add(-2,2); map.Add(-3,3); Console.WriteLine(map.GetValue(-1)); //1 Console.WriteLine(map.GetValue(-2)); //2 Console.WriteLine(map.Delete(-3)); //true map.Clear(); Console.WriteLine(map.Delete(-2)); //false map.Add(-1,10); Console.WriteLine(map.GetValue(-1)); //10 }
public int Zindex = 50; //画面表现层次 #endregion Fields #region Constructors /// <summary> /// 以下是函数部分 /// </summary> /// <param name="gridSize"></param> /// <param name="bimg"></param> /// <param name="p"></param> public MyPerson(double gridSize, List<List<ImageSource>> bimg, System.Drawing.Point p,MyMap map) { InitializeComponent(); //设置布局信息 this.map = map; this.gridSize = gridSize; imgsource = bimg; this.X = p.X * gridSize; this.Y = p.Y * gridSize; position = p; //设置生命值、魔法值信息 MAX_HP = 300; MAX_MP = 300; hp = MAX_HP; mp = MAX_MP; action = Actions.stand; direction = Direction.Up; InitThread(); }