Javascript webpage expect to at least load a map, but actually can't load anything -



Javascript webpage expect to at least load a map, but actually can't load anything -

below html page embedded javascript. map api key valid web domain, , page can load map if hide javascript functions , left initialize() there, google's official illustration code, otherwise see nil after page loaded(i.e. blank page). can help me find 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) { homecoming new activexobject("microsoft.xmlhttp"); } else if(window.xmlhttprequest) { homecoming = new xmlhttprequest(); } } function sendrequest(){ xmlobj = createxmlhttprequest(); if(!xmlobj){ alert('the browser not compatible xmlhttprequest'); homecoming 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(); (var = 0; < 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>

there bug in javascript. createxmlhttprequest should this:

function createxmlhttprequest(){ if(window.activexobject) { homecoming new activexobject("microsoft.xmlhttp"); } else if(window.xmlhttprequest) { homecoming new xmlhttprequest(); } }

note had written:

return = new xmlhttprequest();

javascript google-maps-api-3

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -