0

みなさん、こんにちは。

私はグーグルマップAPIを使用して私のウェブサイトにいくつかのアドレスを表示しようとしています。問題は、IEでは機能しないことです...私のコードは次のようになります:

function displayAdress (address) {

geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        var myOptions = {
            zoom: 15,
            center: results[0].geometry.location,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("gmap-event"),myOptions); ////$("div[id^='map_canvas']").first()
        var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location
        });
    } else {
        alert(
        /*"Geocode was not successful for the following reason: " + status*/
        'Google map was unable to found the address: '+ address
        );
    }
});

IEで使用すると、ログコンソールで問題が発生しますgeocoder = new google.maps.Geocoder();

誰かがこの問題を抱えたことはありますか?助けてくれてありがとう。

トーマス。

4

1 に答える 1

0

私の推測では (十分なコンテキストが含まれていないため)、ページに id="geocode" の要素があり、グローバル コンテキストの JavaScript で "var geocode" を宣言していないということです。

于 2012-12-04T14:20:10.117 に答える