Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9181849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:25:08+00:00 2026-06-17T18:25:08+00:00

I am using WebBroswer in my wpf application to render Google map. So I

  • 0

I am using “WebBroswer” in my wpf application to render Google map. So I am calling Pan(x, y) JavaScript method with some parameters form my c# code.

But I am getting this below error.

Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))

My Window2.xaml File:

<Window x:Class="Test.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window2" Height="300" Width="300">
    <Grid>
        <WebBrowser Name="mapBrowser" Margin="50" />
        <Button Name="button1" VerticalAlignment="Bottom" Click="button1_Click">Button</Button>
    </Grid>
</Window>

My Window2.xaml.cs File:

namespace Test
{
    /// <summary>
    /// Interaction logic for Window2.xaml
    /// </summary>
    public partial class Window2 : Window
    {
        public Window2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Uri uri = new Uri(@"pack://application:,,,/HTMLPage1.htm");
            Stream source = Application.GetContentStream(uri).Stream;
            mapBrowser.NavigateToStream(source);
            this.mapBrowser.InvokeScript("Pan", x, y);
        }
    }
}

My HTML Page:

<html>
<head>
    <title></title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">
        var map;
        var latlng;
        var lat;
        var lng;
        var zoom;

        function Init() {
            lat = 40.632915;
            lng = -8.68929;
            zoom = 18
            latlng = new google.maps.LatLng(lat, lng);
            var options = {
                zoom: 18,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.SATELLITE
            };

            map = new google.maps.Map(document.getElementById("map_canvas"), options);
        }

        function Pan(x, y) {
            try {
                lat = x;
                lng = y;

                map.panTo(new google.maps.LatLng(lat, lng));
            }
            catch (ex) {
                window.alert("Pan:Error");
            }
        }
    </script>

</head>
<body onload="Init()">
    <div id="map_canvas" style="width: 100%; height: 100%">
    </div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:25:09+00:00Added an answer on June 17, 2026 at 6:25 pm

    Yes, I got the problem. I try to call the JavaScript function without loading the HTML page. So I have first loaded the html page and then called the JavaScript function and its working for me.

    So I have changed my code as below and it is working fine :-

    namespace WpfApplication1
    {
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
                Uri uri = new Uri(@"pack://application:,,,/HTMLPage1.htm");
                Stream source = Application.GetContentStream(uri).Stream;
                mapBrowser.NavigateToStream(source);
            }
    
            private void button1_Click(object sender, RoutedEventArgs e)
            {
                try
                {   
                    this.mapBrowser.InvokeScript("Pan", 19.006145, 72.818148);
                }
                catch
                { 
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a WebBrowser component in WPF to host some JavaScript + HTML
I'm using the WPF 3.5SP1 WebBrowser control to display a page containing some javascript
Using WebBrowser on a Form and calling into C# from Javascript with window.external. Passing
I am using WPF WebBrowser control and I want to acces some of the
I'm hosting some web content in a WPF app using the WebBrowser control (or
I'm using the WPF WebBrowser component to display some very simple HTML content. However,
I'm using the C# Twitterizer in a WPF application to authenticate users to Twitter
I need some help using a .NET Wrapper for Google chrome. The problem is
I need to pre-fill some form in some web page within my WPF app
I am creating a wpf application where I am using a webbrowser control. anyways

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.