<StackPanel> <TextBlock Text="Bing Map" FontSize="50" /> <TextBlock Text="Places of Interest" FontSize="25" /> <Controls:Map Name="Bmap" Height="400"/> <StackPanel Orientation="Horizontal"> <TextBlock Text="Latitude :" FontSize="25" /> <TextBlock Text="" FontSize="25" Name="txt_lat" /> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="Longitude :" FontSize="25" /> <TextBlock Text="" FontSize="25" Name="txt_long" /> </StackPanel> </StackPanel>
public static class CoordinateConverter { public static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate) { return new GeoCoordinate ( geocoordinate.Latitude, geocoordinate.Longitude, geocoordinate.Altitude ?? Double.NaN, geocoordinate.Accuracy, geocoordinate.AltitudeAccuracy ?? Double.NaN, geocoordinate.Speed ?? Double.NaN, geocoordinate.Heading ?? Double.NaN ); } } protected async override void OnNavigatedTo(NavigationEventArgs e) { var locator = new Geolocator(); locator.DesiredAccuracyInMeters = 50; // MUST ENABLE THE LOCATION CAPABILITY!!! var position = await locator.GetGeopositionAsync(); var myGeocoordinate = position.Coordinate; txt_lat.Text = position.Coordinate.Latitude.ToString(); txt_long.Text = position.Coordinate.Longitude.ToString(); Bmap.LandmarksEnabled = true; Bmap.PedestrianFeaturesEnabled = true; GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); Bmap.Center = myGeoCoordinate; Bmap.ZoomLevel = 16; // Create a small circle to mark the current location. Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Blue); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; // Create a MapOverlay to contain the circle. MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); // Add the MapLayer to the Map. Bmap.Layers.Add(myLocationLayer); //Use google API to show POI HttpClient client = new HttpClient(); string baseUrl = "https://maps.googleapis.com/maps/api/place/search/json?location=" + position.Coordinate.Latitude + "," + position.Coordinate.Longitude + "&radius=1000&keyword=hospital&sensor=true"; string googleResult = await client.GetStringAsync(baseUrl); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)