Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi ,
Im writing a WPF app to display the map from google maps api.
I was successfuly able to get info from google weather but google maps im not able to display.I dono what is exact reason.

Below is the snippet.


string url = @"http://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&sensor=false";
           WebRequest webrequest = WebRequest.Create(url);
           WebProxy proxy = new WebProxy(addressVar);//, 8080);
           proxy.Credentials = CredentialCache.DefaultCredentials;
           webrequest.Proxy = proxy;
           //XmlTextReader reader = new XmlTextReader(webrequest.GetResponse().GetResponseStream());
           BitmapImage bitmap1 = new BitmapImage();
           bitmap1.BeginInit();
           bitmap1.UriSource = new Uri(url);
           bitmap1.EndInit();

           imageMap.Source = bitmap1;
Posted

To complement Kenneth's answer, here's how you'd do it in C#;
C#
string url = @"http://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&sensor=false";

BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
bmpImage.UriSource = new Uri(mapURL);
bmpImage.EndInit();

MapImage.Source = bmpImage; 
 
Share this answer
 
There is an article that pulls google pictures from the web to display it in a WPF program, the source is written in VB.net but there sould be many hints on how to do it here:
WPF Map App: WPF Meets Google Geocoding and Static Maps APIs[^]
 
Share this answer
 

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