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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:52:26+00:00 2026-06-06T04:52:26+00:00

I’m creating an asp.net page that uses the google map api. The page loads

  • 0

I’m creating an asp.net page that uses the google map api. The page loads GoogleMap.js in the head tag which contains the google map initialization stuff. And in the code behind, I’m injecting some more javascript code using Page.ClientScript.RegisterClientScriptBlock() (I’ve also tried RegisterStartupScript()). This function places the additional injected code in a script block inside the body tag (below the GoogleMap.js script). I’m using the Chrome developer window to debug my javascript, now when I throw in some break points to check the execution sequence, the script block in the body gets executed before the script in the head. So it’s NOT going in sequence from top of the HTML page to the bottom like I thought it should. What’s going on??? And how can I fix it? And for the sake of organization, I’d like to not use RegisterClientScriptBlock() for every piece of javascript in my page.

The issue is that the body tag executes first, and since the “map” variable hasn’t been assigned with a Google map whatever object, the markers don’t get added.

Here’s some code of what asp.net produces and returns to the client browser…

</title><link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" /><link href="../css/master.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>




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



    <script type="text/javascript">
        var map;

        function initialize() {
            var chicago = new google.maps.LatLng(41.879535, -87.624333);

            var mapOptions = {
                zoom: 4,
                center: chicago,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

            var marker = new google.maps.Marker({
                position: chicago,
                map: map,
                title: "Hello World!"
            });

            $('#Debug').html(CountryDropDownList.children("option").filter(":selected").text().trim());
        }

        $(document).ready(function() {
            initialize();
        });
    </script>

    <script src="SearchTabs.js" type="text/javascript"></script>

    <!--[if gte IE 9]>
    <style type="text/css">
    .gradient {
       filter: none;
    }
    </style>
    <![endif]-->
<style type="text/css">
    .ctl00_MainMenu_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }
    .ctl00_MainMenu_1 { text-decoration:none; }
    .ctl00_MainMenu_2 {  }
    .ctl00_MainMenu_3 { font-size:12pt; }
    .ctl00_MainMenu_4 { padding:0px 10px 0px 10px; }

</style></head>
<body>
    <form name="aspnetForm" method="post" action="HertzMap.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="VIEWSTATE_CRAP" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script type="text/javascript">
var marker1 = new google.maps.Marker({
    position: new google.maps.LatLng(41.79068,-77.26577),
    map: map,
    title: "WHEEL LOADER/3YD/GEN BKT/DSL            "
});
var marker2 = new google.maps.Marker({
    position: new google.maps.LatLng(41.72962,-76.12181),
    map: map,
    title: "CRAWLER LOADER/3/4 YD/GENERAL/DSL       "
});
</script>
  • 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-06T04:52:28+00:00Added an answer on June 6, 2026 at 4:52 am

    Looking at:

    $(document).ready(function() {
        initialize();
    });
    

    means that jQuery will delay the execution of initialize until the document has been fully loaded.

    However, if you put code just inside script element, it will be executed right away. This is exactly what you are now doing with the markers: they are initialized, before the actual map object is available, which leads to undesirable results.

    Try calling the script initialization either in the end of the initialize or after it calling it inside $(document).ready.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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
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
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.