が、私は常に、コンソールで次のエラーが表示される機能ではありませんhttps://maps.googleapis.com/maps/api/js?sensor=false&callback=initialiseGoogleマップ - キャッチされないInvalidValueError:これは、</p> <blockquote> <p>Uncaught InvalidValueError: initialise is not a function <em>js?sensor=false&callback=initialise:94</em></p> </blockquote> <p>は、ファイル名の上にマウス:初期化は、私は私のGoogleマップが表示されるページをロードすると
Googleマップのウィンドウとマップは完全に機能し、完全に機能しています。不思議なことに、私はこれに関するGoogleのヒットを見つけることができなかった、彼らはすべてsetLongとsetLatについてのようだ。
API呼び出しとJSファイルの間の読み込み順序を変更すると、エラーメッセージはinitialise
とgoogle
の間で変化します。しかし、どちらの場合も、マップはまだ細かくロードされ続けます。
なぜエラーが発生していますか、どうすれば適切に解決できますか?ここに私のGoogle-map.jsファイルです:
function initialise() {
var myLatlng = new google.maps.LatLng(51.126500, 0.257595); // Add the coordinates
var mapOptions = {
zoom: 15, // The initial zoom level when your map loads (0-20)
disableDefaultUI: true, // Disable the map UI
center: myLatlng, // Centre the Map to our coordinates variable
mapTypeId: google.maps.MapTypeId.ROADMAP, // Set the type of Map
scrollwheel: false, // Disable Mouse Scroll zooming (Essential for responsive sites!)
// All of the below are set to true by default, so simply remove if set to true:
panControl:false, // Set to false to disable
mapTypeControl:false, // Disable Map/Satellite switch
scaleControl:false, // Set to false to hide scale
streetViewControl:false, // Set to disable to hide street view
overviewMapControl:false, // Set to false to remove overview control
rotateControl:false // Set to false to disable rotate control
}
var map = new google.maps.Map(document.getElementById('map'), mapOptions); // Render our map within the empty div
var image = new google.maps.MarkerImage('/wp-content/themes/bellavou/img/marker2.png', null, null, null, new google.maps.Size(70,70)); // Create a variable for our marker image.
var marker = new google.maps.Marker({ // Set the marker
position: new google.maps.LatLng(51.125887, 0.258075), // Position marker to coordinates
icon:image, //use our image as the marker
map: map, // assign the market to our map variable
title: 'Bella Vou at The Pantiles' // Marker ALT Text
});
}
google.maps.event.addDomListener(window, 'load', initialise); // Execute our 'initialise' function once the page has loaded.
コードを掲載しないと、どうすれば助力できますか? – MrUpsidown
あなたがそれを必要としているかどうかわかりませんが、大丈夫です。 – Lee
まず、API呼び出しでコールバックを定義します。 'https://maps.googleapis.com/maps/api/js?sensor=false&callback=initialise次に、リスナー 'google.maps.event.addDomListener(window、 'load'、initialise);を追加します。これは基本的に同じです。そのリスナー行を削除するか、APIコールから 'callback = initialise'を削除して、それがうまくいくかどうか私たちにお知らせください。 – MrUpsidown