Google Maps APIを使用して、ユーザーが提供する場所を取得しようとしています。これを行うには、「クリック」イベントに基づいて移動するマーカーを設定します。Google Maps API google.maps.eventが定義されていません
function initialize_google_map(div_id) {
var map = new GMap2(document.getElementById(div_id));
map.setCenter(new GLatLng(45, -105), 2);
map.setUIToDefault();
return map;
}
$(document).ready(function() {
// configure the google maps api
var map = initialize_google_map("map_canvas");
var marker = google.maps.Marker({map: map, title:"Location"});
google.maps.event.addListener(map, "click", function(evt) {
alert("got click event");
marker.setPosition(evt.latLng);
});
$(document).unload(function() {
// unload the google map
GUnload();
});
});
アラートは決して発射されていない "イベントをクリックしました"、と私のJavaScriptコンソール(Google Chromeは)この言葉::のようなコードがある
Uncaught TypeError: Cannot call method 'addListener' of undefined
APIは、この
のように含まれています<script src="http://maps.google.com/maps?file=api&v=3&sensor=true" type="text/javascript"></script>
素晴らしい、ありがとうございました!私はそれが見つからないとは信じられません。 –
@ john-dorn問題なし:) – RedBlueThing