-1

JSP に Google マップ スクリプトを含めました。src="http://maps.googleapis.com/maps/api/js?sensor=true"

そして今、別の外部jsファイルでこのスクリプトを使用してマップを作成しようとしています

var mapOptions = {
      center : new google.maps.LatLng(centerLat,centerLong),
      zoom : 11,
      mapTypeId : google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
        mapOptions);

私がそれを実行しようとしていたとき、「Googleが定義されていません」というjsエラーが発生しました。外部jsファイルにgoogle maps api3を実装する他の可能性はありますか?

4

1 に答える 1

0

Most probably your code is trying to run before Google Maps API is fully initialized. you better try to hold on the execution until the maps API is fully loaded.

1- Make sure that you reference Google maps script before your custom file. 2- try to hold on the execution using document.load or using jQuery's document.ready().

let me know what happened after applying the mentioned advices.

于 2012-09-05T11:19:53.453 に答える