Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using map control in windows phone 8. I have to show places on map within 10km nearby my current location. Till then i am able to show my current location and i have latitude & longitude.
Please tell me how to do this task.
HTML
<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>


C#
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);
}


Someone told me to use google api to show the POI but i don't know how to use. I am beginner in WP app development. Plz help.
Posted
Comments
[no name] 30-Jun-15 8:55am    
If you are a beginner, then maybe you should be reading the API documentation.
Raj Negi 30-Jun-15 11:32am    
Actually i have to complete task ASAP. Surely i will read from beginning but i need it very urgent. Plz send if you know any reference link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900