public MapView() { InitializeComponent(); var ubication = new Point(-3.7025600, 40.4165000); var sphericalMercatorCoordinate = SphericalMercator.FromLonLat(ubication.X, ubication.Y); var mapControl = new MapsUIView(); mapControl.NativeMap.NavigateTo(sphericalMercatorCoordinate); mapControl.NativeMap.Layers.Add(OpenStreetMap.CreateTileLayer()); mapControl.NativeMap.NavigateTo(mapControl.NativeMap.Resolutions[9]); var layer = GenerateIconLayer(); mapControl.NativeMap.Layers.Add(layer); mapControl.NativeMap.InfoLayers.Add(layer); ContentGrid.Children.Add(mapControl); mapControl.NativeMap.Info += (sender, args) => { var layername = args.MapInfo?.Layer.Name; var featureLabel = args.MapInfo.Feature?["Label"]?.ToString(); var featureType = args.MapInfo.Feature?["Type"]?.ToString(); if (featureType != null && featureType.Equals("Point")) { ShowPopup(featureLabel); } }; }
private void CreateMap() { var mapControl = new MapsUIView(); mapControl.NativeMap.Layers.Add(OpenStreetMap.CreateTileLayer()); var layer = GenerateIconLayer(); mapControl.NativeMap.Layers.Add(layer); mapControl.NativeMap.InfoLayers.Add(layer); mapControl.NativeMap.Info += (sender, args) => { var layername = args.Layer?.Name; var featureLabel = args.Feature?["Label"]?.ToString(); var featureType = args.Feature?["Type"]?.ToString(); Debug.WriteLine("Info Event was invoked."); Debug.WriteLine("Layername: " + layername); Debug.WriteLine("Feature Label: " + featureLabel); Debug.WriteLine("Feature Type: " + featureType); Debug.WriteLine("World Postion: {0:F4} , {1:F4}", args.WorldPosition?.X, args.WorldPosition?.Y); Debug.WriteLine("Screen Postion: {0:F4} , {1:F4}", args.ScreenPosition?.X, args.ScreenPosition?.Y); }; this.MapGrid.Children.Add(mapControl); }