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

  • Home
  • SEARCH
  • 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 8300573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:36:49+00:00 2026-06-08T16:36:49+00:00

I’m developing an application in which the user will be able to enter a

  • 0

I’m developing an application in which the user will be able to enter a desired address and then press a button. This address will be found on the WebBrowser control in a .net windows application. I know that you can run javascripts on WebBrowser by using the WebBrowser1.DocumentText, and the calling the script by WebBrowser1.Document.InvokeScript …

I’m having little issues with this and I was wondering if someone could show me the right way in order to do it.

CODE:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

  Dim AddressMap As String

  AddressMap = AddressM.Text

  WebBrowser1.DocumentText = "<html><head><meta name='viewport' content='initial-scale=1.0, user-scalable=no' />" & _
    "<script type='text/javascript' src='http://maps.google.com.mx/maps/api/js?sensor=true&language;=es'></script>" & _
    "<script type='text/javascript'>" & _
    "var geocoder; var map;" & _
    "function initialize() " & _
    "{geocoder = new google.maps.Geocoder(); var myOptions = { zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP()" & _
    "} var(address = " & AddressMap & ")" & _
    "geocoder.geocode({ 'address': address }, function (results, status) {" & _
                    "if (status == google.maps.GeocoderStatus.OK) {" & _
                        "map.setCenter(results[0].geometry.location);" & _
                        "var marker = new google.maps.Marker({" & _
                           " map: map," & _
                            "position: results[0].geometry.location });" & _
                    "} else {" & _
                    "}});" & _
     "map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);}" & _
     "</script></head><div id='map_canvas' style='width:100%; height:100%'></div></body></html>"

   WebBrowser1.Document.InvokeScript("Initialize")

End Sub

below is another piece of code that i think should work but i still get an script error “An error has occured in the script on this page” Line 1 CHar 124 Error Expected ‘;’ Code 0 URL about.blank

 WebBrowser1.DocumentText = "<html><head><script type='text/javascript' src='http://maps.google.com.mx/maps/api/js?sensor=false&language;=es'></script> " +
                           "<script type='text/javascript'> " +
                           "var geocoder; " +
                           "var map; " +
                           "function initialize(address) { " +
                           "geocoder = new google.maps.Geocoder(); " +
                           "var myOptions = { zoom: 16 } " +
                           "geocoder.geocode({ 'address': address }, function (results, status) { map.setCenter(results[0].geometry.location); " +
                           "var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); " +
                           "map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); " +
                           "} " +
                           "</script> " +
                           "</head> " +
                           "<body> <div id='map_canvas' style='width:100%; height:100%'></div> </body> </html>"

WebBrowser1.Document.InvokeScript("initialize", New String() {AddressM.Text})

i greatly appreciate the help

Leo P.

this is another piece of code slightly different that the previous two, it includes and if else statement pulled out from a html that actually runs the google maps script.

WebBrowser1.DocumentText = "<html><head><script type='text/javascript' src='http://maps.google.com.mx/maps/api/js?sensor=false&language;=es'></script> " +
                       "<script type='text/javascript'> " +
                       "var geocoder; " +
                       "var map; " +
                       "function initialize() { " +
                       "geocoder = new google.maps.Geocoder(); " +
                       "var myOptions = { zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP } " +
                       "var(address = 'Miami Beach, Flordia') " +
                       "geocoder.geocode({ 'address': address }, " +
                       "function (results, status) { " +
                       "if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); " +
                       "var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); " +
                       "} else { alert('Geocode was not successful !);}}); " +
                       "map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); } " +
                       "</script> " +
                       "</head> " +
                       "<body> <div id='map_canvas' style='width:100%; height:100%'></div> </body> </html>"

        WebBrowser1.Document.InvokeScript("initialize")

html code below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<script type="text/javascript" src="http://maps.google.com.mx/maps/api/js?sensor=true&language=es"></script>
<script type="text/javascript">

    var geocoder;
    var map;


    function initialize() {

        geocoder = new google.maps.Geocoder();

        var myOptions = {
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        //var address = document.getElementById("address").value;
        var address = "Miami Beach, Flordia" //change the address in order to search the google maps

        geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });

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


    </script>
  </head>
  <body onload="initialize()">
    <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-08T16:36:53+00:00Added an answer on June 8, 2026 at 4:36 pm

    Putting solution

    HTML

    Create page html in C:\page.html and using this code

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    
    <script type="text/javascript" src="http://maps.google.com.mx/maps/api/js?sensor=true&language=es"></script>
    <script type="text/javascript">
    
        var geocoder;
        var map;
    
    
        function initialize(address) {
    
            geocoder = new google.maps.Geocoder();
    
            var myOptions = {
                zoom: 16,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
    
            geocoder.geocode({ 'address': (address ? address : "Miami Beach, Flordia")}, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location
                    });
                } else {
                    alert("Geocode was not successful for the following reason: " + status);
                }
            });
    
            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        }
    
    
        </script>
      </head>
      <body onload="initialize()">
        <div id="map_canvas" style="width:100%; height:100%"></div>
    
      </body>
    </html>
    

    Windows Form – C#

    private void Form1_Load(object sender, EventArgs e)
    {
        // Put uri (http://www.example.com/page.html and c:\page.html is valid address)
        webBrowser1.Url = new Uri(@"C:\page.html");
    }
    
    private void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.Document.InvokeScript("initialize", 
                new string[] { textBox1.Text });
    }
    

    and need form with this component with this names: textBox1, button1 and webBrowser1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.