简体   繁体   中英

Google Maps Api v3 custom InfoWindow - “google is not defined” error

trying to create custom infowindows in my application that is based on google maps.

problem is that whatever i use this or some other example, in forefox's firebug i'm getting error

google is not defined InfoBox.prototype = new google.maps.OverlayView();

can you help me how to solve this, i can not continue my work without custom infowindows..... and i include the following script files in my page

<script src="http://www.google.com/jsapi" type="text/javascript" language="javascript"></script> 

<script type="text/javascript">
 var script = '<script type="text/javascript" src="../Scripts/markerclusterer';
 var script1 = '<script type="text/javascript" src="../Scripts/infobox';
 if (document.location.search.indexOf('packed') !== -1) {
     script += '_packed';
 }
 if (document.location.search.indexOf('compiled') !== -1) {
     script += '_compiled';
 }
 script += '.js"><' + '/script>'; script1 += '.js"><' + '/script>';
 document.write(script);
 document.write(script1);
</script>

您应该等待Javascript完成加载后再使用它:尝试在body :: onLoad事件处理程序中进行操作(新的google.maps ...),应该没问题。

<script type="text/javascript">
var gmap;
initializemap();
    function initializemap() {

                  var myOptions = {
                      center: new google.maps.LatLng(15.019500, 120.703600),
                      zoom: 10,
                      mapTypeId: google.maps.MapTypeId.TERRAIN
                  };

                  gmap = new google.maps.Map(document.getElementById("map_canvas"), myOptions);


}
</script>

you need to initialize the map itself like what iv'e use in the initializemap() function document.getElementById("map_canvas") div with id map_canvas make sure to put width 100% and height 100% on the form tag or else it wont show the map from google this is what happens on my part

Please add google map api library " http://maps.google.com/maps/api/js?sensor=false " Correct position.

These seems to be arise problems if you will not place the js in proper position.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM