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 8467729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:43:41+00:00 2026-06-10T15:43:41+00:00

a while back someone from stackoverflow helped me come with a nice solution to

  • 0

a while back someone from stackoverflow helped me come with a nice solution to using google maps api on windows application

html 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 application code

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Document.InvokeScript("initialize", New String() {AddressM.Text})

    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        WebBrowser1.Url = New Uri("http://datasharesas.com/CompanyAdmin/map2.html")
    End Sub
End Class

image of the project

now the issue is that when i look the same address once, it works perfectly.
when i search it twice i get a grey screen and when i search more than 3 times i get an error script

error message

how can this be fixed ?

thank you in advance,

Leo P.

  • 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-10T15:43:43+00:00Added an answer on June 10, 2026 at 3:43 pm

    Geocoding is asynchronous, so in some cases, (depending on how fast it returns), your map is not yet created when you try to use it. You need to create the map first and geocode afterwrds. Try this instead:

        script type="text/javascript">
        // Global vars
        // Sorry, I can't be bothered typing "google.maps." every time. ;-)
           var G = google.maps;
           var map;
           var geocoder = new G.Geocoder();
    
            function initialize() {
              createMap();
              geocode('Chicago');
            }
    
            function createMap() {
                var myOptions = {
                    center: new G.LatLng(0,0),
                    zoom: 4,
                    mapTypeId: G.MapTypeId.ROADMAP
                }
                map = new G.Map(document.getElementById("map_canvas"), myOptions);
            }
    
    function geocode(address){
                geocoder.geocode({ 'address': (address ? address : "Miami Beach, Florida")}, function (results, status) {
                    if (status == G.GeocoderStatus.OK) {
                        map.setCenter(results[0].geometry.location);
                        var marker = new G.Marker({
                            map: map,
                            position: results[0].geometry.location
                        });
                    } else {
                        alert("Geocode was not successful for the following reason: " + status);
                    }
                });
    
            }
    
    
            </script>
          </head>
          <body onload="initialize()">
            <div id="map_canvas" style="width:100%; height:100%"></div>
    
          </body>
        </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A while back, I remember using a piece of code (4-5 lines), added to
A while back, smart clients had been touted as the solution to occasional connected
A while back I wrote a simple python program to brute-force the single solution
A while back I created a lightbox plugin using jQuery that would load a
A while back I was playing with methods using variable-length argument lists (java) that
I'm using the Zend framework and the openid selector from http://code.google.com/p/openid-selector/ - however I
I've been using Android for only a little while. In my application, I have
I am using SQL Server 2008. A while back, I asked the question should
A while back I compiled two versions of a code, one using (Nullable<T>)x.GetValueOrDefault(y) and
A while back i read somewhere about how to improve upon the MVC pattern

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.