private async Task drawMapIconsAsync() { // How to draw a new MapIcon with a label, anchorpoint and custom icon. // Icon comes from shared project assets var anchorPoint = new Point(0.5, 0.5); List <Place> places = await Place.GetPlacesAsync(); this.DefaultViewModel["Places"] = places; foreach (var dataObject in places) { /////////////////////////////////////////////////// // Creating the MapIcon if description is not null // (text, image, location, anchor point) if (dataObject.Description != null) { var shape = new MapIcon { Title = dataObject.Name, Location = dataObject.Position, NormalizedAnchorPoint = anchorPoint, ZIndex = 5 }; shape.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/MapIcons/" + dataObject.Kind.ToString() + ".png")); shape.AddData(dataObject.Description); MyMap.MapElements.Add(shape); } } }
private void DrawPoints(object sender, RoutedEventArgs e) { // How to draw a new MapIcon with a label, anchorpoint and custom icon. // Icon comes from shared project assets var anchorPoint = new Point(0.5, 0.5); var image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/wplogo.png")); // Helper extension method var area = MyMap.GetViewArea(); // GeoboundingBox countains two BasicGeopositions.... // PointList is just a helper class that gives 'some data' var points = PointList.GetRandomPoints(new Geopoint(area.NorthwestCorner), new Geopoint(area.SoutheastCorner), 50); foreach (var dataObject in points) { /////////////////////////////////////////////////// // Creating the MapIcon // (text, image, location, anchor point) var shape = new MapIcon { Title = dataObject.Name, Location = dataObject.Points.First(), NormalizedAnchorPoint = anchorPoint, Image = image, ZIndex = 5 }; shape.AddData(dataObject); MyMap.MapElements.Add(shape); } }
private void AddBuilding(Building building) { var ancherPoint = new Point(0.5, 1); var image = RandomAccessStreamReference.CreateFromUri( new Uri("ms-appx:///Res/" + building.GetBuidlingType() + building.IsBought() + ".png")); var buildingElement = new MapIcon { Title = building.Name, Location = new Geopoint(building.getPosistion()), NormalizedAnchorPoint = ancherPoint, Image = image, ZIndex = 20 }; buildingElement.AddData(building); _myMap.MapElements.Add(buildingElement); }
// -------------------- DRAWING STUFF ON THE MAP ----------------------- private async void DrawPoints(object sender, RoutedEventArgs e) { // How to draw a new MapIcon with a label, anchorpoint and custom icon. // Icon comes from project assets var anchorPoint = new Point(0.5, 0.5); var image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/wplogo.png")); // Helper extension method try { var area = MyMap.GetViewArea(); // PointList is just a helper class that gives 'some data' var points = PointList.GetRandomPoints( new Geopoint(area.NorthwestCorner), new Geopoint(area.SoutheastCorner), 50); foreach (var dataObject in points) { var shape = new MapIcon { Title = dataObject.Name, Location = new Geopoint(dataObject.Points.First()), NormalizedAnchorPoint = anchorPoint, Image = image, CollisionBehaviorDesired = onCollisionShow? MapElementCollisionBehavior.RemainVisible : MapElementCollisionBehavior.Hide, ZIndex = 3, }; shape.AddData(dataObject); MyMap.MapElements.Add(shape); } } catch (Exception) { var dialog = new MessageDialog("GetViewArea error"); await dialog.ShowAsync(); } }
private void RedrawSight(MapIcon icon) { foreach (MapElement mapElement in _map.MapElements) { if (mapElement.GetType() != typeof(MapIcon)) { continue; } if (mapElement.Equals(icon)) { int index = _map.MapElements.IndexOf(mapElement); _map.MapElements.RemoveAt(index); RandomAccessStreamReference image; Sight s = icon.ReadData(); if (s.Name != "VVV") { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/entered-pin.png")); } else { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/home-entered-pin.png")); } var ancherpoint = new Point(0.5, 1); var seenSight = new MapIcon { Title = s.Name, Location = s.Position, NormalizedAnchorPoint = ancherpoint, Image = image, ZIndex = 4, CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible }; seenSight.AddData(s); _map.MapElements.Add(seenSight); break; } } }
public void drawSight(List <Sight> list) { var ancherpoint = new Point(0.5, 1); RandomAccessStreamReference image; foreach (Sight sight in list) { MapIcon sightIcon; if (sight.Name == "VVV") { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/home-pin.png")); } else if (sight.Name == "") { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/TransparentWayPoint.png")); } else { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/pin.png")); } sightIcon = new MapIcon { Title = sight.Name, Location = sight.Position, NormalizedAnchorPoint = ancherpoint, Image = image, ZIndex = 4, CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible }; sightIcon.AddData(sight); _map.MapElements.Add(sightIcon); AddGeofence(sight.Position, sight.Name, 20); //_map.MapElements.Add(GetCircleMapPolygon(sight.Position.Position, 20)); } }