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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:38:06+00:00 2026-05-28T03:38:06+00:00

Below is that html page embedded with Javascript. The Map API Key is valid

  • 0

Below is that html page embedded with Javascript. The Map API Key is valid for my web domain, and the page can load the map only if I hide all the Javascript functions and left the initialize() there, just like some Google’s official example code,
Otherwise I see nothing after the page is loaded(i.e. blank page).
Can someone help me find the reason why?

Thanks!

<html>   
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Real-time iphone tracker</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzcrhlFUxvQMBI3qYkY87zhStzVKTwp4tXCAZpL7xj82pGpEoixSAvciDeL2RO_S1xLoGgxKBpbG6HQ&sensor=true"
        type="text/javascript"></script>
<script type="text/javascript">

var xmlobj;
function createXMLHttpRequest(){
   if(window.ActiveXObject)
   {
       return new ActiveXObject("Microsoft.XMLHTTP");
   }

   else if(window.XMLHttpRequest)
   {
       return = new XMLHttpRequest();
   }
}

function sendRequest(){

    xmlobj = createXMLHttpRequest();
    if(!xmlobj){
        alert('The browser is not compatible with XMLHttpRequest');
        return 0;
    }
    var indexurl = "index.php";
    xmlobj.onreadystatechange = stateHandler;
    xmlobj.open("GET", indexurl, true);
    xmlobj.send(null);

}
function stateHandler(){
  if(xmlobj.readyState == 4 && xmlobj.status == 200){
    document.getElementById("map_data").innerHTML= xmlobj.responseText;
  }
}

function initialize() {
  if (GBrowserIsCompatible()) {
    sendRequest();
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(22.37664, 114.184902), 13);
    map.setUIToDefault();

    var bounds = map.getBounds();
    var southWest = bounds.getSouthWest();
    var northEast = bounds.getNorthEast();
    var lngSpan = northEast.lng() - southWest.lng();
    var latSpan = northEast.lat() - southWest.lat();
    for (var i = 0; i < 10; i++) {
      var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
                              southWest.lng() + lngSpan * Math.random());
      map.addOverlay(new GMarker(point));
    }
  }
}
</script>
</head>
<body onload="initialize()" >
<div id="map_canvas" style="width: 500px; height: 300px"></div>
<br>
<div> id="map_data" ></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-05-28T03:38:07+00:00Added an answer on May 28, 2026 at 3:38 am

    There was a bug in your JavaScript. The createXMLHttpRequest should be like this:

    function createXMLHttpRequest(){
       if(window.ActiveXObject)
       {
           return new ActiveXObject("Microsoft.XMLHTTP");
       }
    
       else if(window.XMLHttpRequest)
       {
           return new XMLHttpRequest();
       }
    }
    

    Note you had written:

    return = new XMLHttpRequest();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is a complete html page that shows the problem. The myDiv should be
I have a link that can not be identified in my html page shown
I have a .Net 2.0 activex control that is embedded within an HTML page
I have a HTML page that contains a flash file and some a JavaScript
Below are the options that I have in my HTML code: <label id="subn"> <select
I have a page (below) that has a datagrid that lists item's returned from
I have this line below that shows a link to go the next page
I have this javascript code below that uses jquery, it is suppoed to be
I have a page with a fixed header and below that a table that
I have a simple HTML page (ratings.html) that I'm trying to test using HtmlUnit.

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.