I have 2 javascripts registered to a page. One being for google maps api and the other being the initialization function to get the map loaded and created. Now whichever one I put first will successfully work, but whichever I put second will not load properly. So If i put the googleapi first, firebug will tell me initialize doesn't exist and vise versa. So h开发者_Go百科ow can i get both to be loaded successfully. Below is the page and JS
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false" />
<script type="text/javascript">
function initialize() {
var myLatLng = new google.maps.LatLng(43.652073, -79.382293);
var myOptions = {
zoom: 8,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
<asp:ContentPlaceHolder ID="Header" runat="server">
<ucHead:UC_Header runat="server" ID="UC_Header" />
</asp:ContentPlaceHolder>
</head>
<body onload="initialize()">
<div class="sidePanel">
<ucMenu:UC_Menu runat="server" ID="UC_Menu" />
</div>
<div class="mainContent">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</body>
</html>
You must close your script tags...
You cannot do this:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false" />
It must look like this:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false" ></script>
You need a </script>
tag after the googleapis.com script tag.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false" /></script>
精彩评论