Click here to Skip to main content
15,893,644 members
Articles / Web Development / HTML

Google Maps in WPF with WebBrowser and Google Maps API v3

Rate me:
Please Sign up or sign in to vote.
4.69/5 (15 votes)
13 Mar 2017CPOL5 min read 125.7K   13.3K   51  
You can show a map in your WPF application with the Google Maps API v3.
<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="595.504" Width="948.881">
    <DockPanel Loaded="DockPanel_Loaded" Name="panel1">
        <Label DockPanel.Dock="Top" VerticalAlignment="Center"  Background="#FF30690B" >
            <TextBox Text="Clients" Foreground="White" Background="#FF30690B" HorizontalAlignment="Stretch" FontSize="20" FontWeight="Normal" FontFamily="Tahoma"   />

        </Label>
        <Grid DockPanel.Dock="Left" Name="datos" Width="386" HorizontalAlignment="Left">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="139"/>
                <ColumnDefinition Width="261"/>
            </Grid.ColumnDefinitions>
            <TextBox Height="29" HorizontalAlignment="Left" Margin="34,248,0,0" Name="textBox1" VerticalAlignment="Top" Width="64" Text="Name:" Foreground="White" FontSize="16" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="34,288,0,0" Name="textBox2" Text="Direction:" VerticalAlignment="Top" Width="84" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="34,330,0,0" Name="textBox4" Text="City:" VerticalAlignment="Top" Width="84" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="34,370,0,0" Name="textBox6" Text="State:" VerticalAlignment="Top" Width="84" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="34,409,0,0" Name="textBox8" Text="Location:" VerticalAlignment="Top" Width="84" BorderThickness="0" >
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="34,205,0,0" Name="textBox3" Text="ID:" VerticalAlignment="Top" Width="64" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>

            <TextBox Grid.Column="1" FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="10,205,0,0" Name="tbID" Text="1" VerticalAlignment="Top" Width="64" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox Grid.Column="1"  FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="10,248,0,0" Name="tbName" Text="Ion Spa" VerticalAlignment="Top" Width="64" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox Grid.Column="1"  FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="10,288,0,0" Name="tbDirection" Text="Saltillo 400 #802" VerticalAlignment="Top" Width="143" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox Grid.Column="1"  FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="10,330,0,0" Name="tbCity" Text="Torreón" VerticalAlignment="Top" Width="64" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox Grid.Column="1"  FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="10,370,0,0" Name="tbState" Text="Coahuila" VerticalAlignment="Top" Width="85" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <TextBox Grid.Column="1"  FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="10,409,0,0" Name="tbLocation" Text="25.520581,-103.40607" VerticalAlignment="Top" Width="168" BorderThickness="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <Image Height="172" HorizontalAlignment="Left" Margin="21,13,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="210" Grid.Column="1" Source="Images/client1.png" />
            <TextBox BorderThickness="0" FontSize="16" Foreground="White" Height="29" HorizontalAlignment="Left" Margin="34,89,0,0" Name="textBox5" Text="Picture:" VerticalAlignment="Top" Width="64" Grid.Column="0">
                <TextBox.Background>
                    <SolidColorBrush />
                </TextBox.Background>
            </TextBox>
            <Button Content="How to Arrive" Height="23" HorizontalAlignment="Left" Margin="23,455,0,0" Name="button1" VerticalAlignment="Top" Width="95" Click="button1_Click" />
            <Button Content="Map" HorizontalAlignment="Left" Margin="23,488,0,-7" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
            <Button Content="Add marker" Grid.Column="1" HorizontalAlignment="Left" Margin="36,455,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
            <Grid.Background>
                <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                    <GradientStop Color="#FF0D2462" Offset="0" />
                    <GradientStop Color="#FF4A95BA" Offset="1" />
                </LinearGradientBrush>
            </Grid.Background>
        </Grid>
        <WebBrowser DockPanel.Dock="Right" Loaded="setupObjectForScripting" Name="webBrowser1" />

    </DockPanel>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer armheSistemas
Mexico Mexico
I'm a software developer. I like to develop web pages and desktop systems. I'm learning unity, xamarin, swift, android, security, UX

Comments and Discussions