1
私は問題を抱えています。JQuery、Googleマップ:「初期化の前にgmapでメソッドを呼び出せません」
正常に動作するコードブロックがありますが、いくつかのJQueryを追加するとすべてがクラッシュします。
私は次のエラーを取得する:「キャッチされないが、従来の初期化にGMAPのメソッドを呼び出すことはできませんが、メソッドを呼び出そうとしました「addMarker」
障害のあるコードは、 『$の.each(markersList.markers、』
から始まります正しい方向に私を指摘するために、任意の助けをいただければ幸いです。ありがとう!
function initialize() {
var myOptions = {
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
$.each(markersList.markers,
function(map, marker) {
var destination = (marker.lat + ', ' + marker.lng);
$('#map_canvas').gmap('addMarker',
{ 'position': new google.maps.LatLng(marker.lat, marker.lng), 'title': marker.title }, function(map, marker) {
$('#map_canvas').gmap('addInfoWindow',
{ 'content': null }, function(iw) {
$(marker).click(function() {iw.open(map, marker);
map.panTo(marker.getPosition());
$('#to').val(destination);
alert("You've selected " + marker.title + " as your destination. Please enter the origin");
});
});
});
});
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
contentString = "Your location was found and has been added to starting point.";
map.setCenter(initialLocation);
$('#from').val(initialLocation);
}, function() {
handleNoGeolocation(browserSupportFlag);
});