Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to display places within 1 km from my current location on window phone 8 map control with google places API. I am using JSON parsing to fetch latitude, longitude and Name. Now i want name to be display like a tooltip when user tap on any place circle.
C#
//Use google API to show POI
HttpClient client = new HttpClient();
string baseUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + position.Coordinate.Latitude + "," + position.Coordinate.Longitude + "&radius=1000&keyword=hospital&key=AIzaSyBCccOYAea2ITvgqNpIHcutuExQwzQctCk";
string googleResult = await client.GetStringAsync(baseUrl);

//Parse JSON data
JObject obj = JObject.Parse(googleResult);
JArray jarr = (JArray)obj["results"];

foreach(var item in jarr)
            {
                string name = (string)item.SelectToken("name");
                double lt = (double)item.SelectToken("geometry.location.lat");
                double lg = (double)item.SelectToken("geometry.location.lng");
                
                //Create a small circle to mark the current location.
                Ellipse myCircle2 = new Ellipse();
                myCircle2.Fill = new SolidColorBrush(Colors.Red);
                myCircle2.Height = 10;
                myCircle2.Width = 10;
                myCircle2.Opacity = 50;

                // Create a MapOverlay to contain the circle.
                MapOverlay myLocationOverlay2 = new MapOverlay();
                myLocationOverlay2.Content = myCircle2;
                myLocationOverlay2.PositionOrigin = new Point(0.5, 0.5);
                GeoCoordinate myGeoCoordinate2 = new GeoCoordinate(lt, lg);
                myLocationOverlay2.GeoCoordinate = myGeoCoordinate2;

                // Create a MapLayer to contain the MapOverlay.
                MapLayer myLocationLayer2 = new MapLayer();
                myLocationLayer2.Add(myLocationOverlay2);

                // Add the MapLayer to the Map.
                Bmap.Layers.Add(myLocationLayer2);

            }
Posted
Updated 2-Jul-15 10:33am
v2

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