Question Google Static Map Image is not getting displayed

kbsudhir

Member
Joined
Jun 13, 2008
Messages
21
Programming Experience
Beginner
Hi All,

I have created a form with Element Host control. I want to load a static map image on Element Host control when form is loaded. But the same is not happening :-(.

Below is my code.

VB.NET:
Expand Collapse Copy
[/FONT][FONT=book antiqua]Imports System.Windows.Media.Imaging 'Added reference to PresentationCore for WPF image capabilities[/FONT]
[FONT=book antiqua]
[/FONT]
[FONT=book antiqua]Public Class Form1[/FONT]
[FONT=book antiqua]    Private ehImage As System.Windows.Controls.Image = New System.Windows.Controls.Image() 'Added Element Host from WPF section in toolbox[/FONT]
[FONT=book antiqua]    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load[/FONT]
[FONT=book antiqua]
[/FONT]
[FONT=book antiqua]        Dim mpMap As New BitmapImage() 'added reference to WindowsBase and System.XAML[/FONT]
[FONT=book antiqua]        mpMap.BeginInit()[/FONT]
[FONT=book antiqua]        mpMap.CacheOption = BitmapCacheOption.OnDemand 'Cahce only when needed[/FONT]
[FONT=book antiqua]        Dim siteUri As New Uri("http://www.google.com")[/FONT]
[FONT=book antiqua]        mpMap.UriSource = siteUri '"http://maps.googleapis.com/maps/api/staticmap?center=40.2394533,-74.2303905&zoom=12&size=400x400&sensor=false"[/FONT]
[FONT=book antiqua]        mpMap.EndInit()[/FONT]
[FONT=book antiqua]
[/FONT]
[FONT=book antiqua]        ElementHost.Child = ehImage 'Set child control in element host[/FONT]
[FONT=book antiqua]        ehImage.Source = mpMap 'Set Image source[/FONT]
[FONT=book antiqua]    End Sub[/FONT]
[FONT=book antiqua]End Class[/FONT]
[FONT=book antiqua]

Please guide on where am I going wrong.

Regards
Sudhir


 
Just use a PictureBox control and set its ImageLocation property to the image url.
 
Back
Top