ユーザーがWebフォームに入力するアドレスのマーカーを表示しようとしています。またアドレスを可視化するときに、メソッド 'getSouthWest'を未定義と呼び出すことはできません。
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
//Remove all markers from the map
clearMarkers();
//Display the new marker on the map
showFullAddressesOnMap(latitude, longitude, address);
//Center the map according to the marker
map.fitBounds(results[0].geometry.bounds);
}
});
function showFullAddressesOnMap(latitude, longitude, fullAddress) {
displayMarker(-1, "", "", "", fullAddress, true, latitude, longitude);
}
function displayMarker(appID, title, image, imageType, address, markerType, lat, lng) {
var listingLatLng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: listingLatLng,
map: map,
icon: markerType ? imgBluePin : imgGreenPin,
title: title + address
});
var content = GetContent(appID, title, image, imageType, address);
marker.info = new google.maps.InfoWindow({
content: content,
size: new google.maps.Size(50, 50)
});
google.maps.event.addListener(marker, 'click', function() {
closeAllWindows();
marker.info.open(map, marker);
});
bounds.extend(listingLatLng);
map.fitBounds(bounds);
markers.push(marker);
}
:問題は、私は次のエラー
は、メソッドを呼び出すことはできません取得していますことを「getSouthWest」未定義
の私は、次のコードを使用して、マーカーを表示しようとすると、あります、エラーは毎回発生しません。ここにコードをクラッシュさせるアドレスがあります。
フランス、イルドフランス、パリ、75006、パリ、7 RUEのカシミールデラヴィグネ
私はFitBounds
が呼び出されたときにエラーが発生していると思います。エラーが発生すると、ジオコーディングによって返された境界が州レベルにズームアウトされます。
エラーの原因を教えてください。ユーザーがストリート名でアドレスを入力すると、マップをストリートレベルにズームする必要があります。
が、なぜジオコードは何の境界を返しません。さらに、それはなぜ時々起こるのですか? – Thea
ジオコーディングによって返された境界を信頼することはできません。ドキュメント内で読めるように、「適用可能な場合」に返されます。あなたが使用した住所は正確なポイント、通り番号を返すので、境界を持つことができるエリアはありません。 –
はい、ジオコーディングは境界に対して「未定義」を返します。これは通りの名前と番号を追加すると発生しますが、「フランス、パリ、75006」と入力するだけでOKです。ストリートの名前と番号でも完全な住所を見つけることができますが、境界を見つけることができないのはなぜですか? – Thea