谷歌地图不适用于IE浏览器

时间:2013-07-10 13:21:47

标签: javascript google-maps

我有一个谷歌地图显示在一个页面上,它在其他浏览器上运行良好,除了IE 8不确定IE的上述版本..

问题是,大多数用户使用IE,我想解决为什么这不适用于IE?

$table = "";
        while ( $row = mysql_fetch_array($result)) {

            $table .= "<table border = \"1\" width=\"800px\">  

                    <tr><td style = \"background:#EEEEEE;\"><b>Arka</b></td>   <td align=\"left\" width= \"220px\" style = \"background:#EEEEEE;\">{$row['arka']}</td> <td width = \"480px\" rowspan = \"4\"> <div style = \"width:480px; height:230px;\" id= \"div-{$row['id']}\">Map here</div></td> </tr>
            <tr><td><b>Orari</b></td>  <td align=\"left\">{$row['orari']}</td></tr>  
            <tr><td><b>Pauza</b> </td>  <td align=\"left\">{$row['pauza']}</td></tr>  
            <tr><td><b>Shtune</b></td> <td align=\"left\">{$row['shtune']}</td></tr>  
            </table> <br>";

            echo '<script type="text/javascript" language="javascript">loadMap("'.$row['adresa'].'",'.$row['id'].');</script>';

            }
            echo $table;
                ?>

这里是加载地图的函数:

function loadMap(street,div_id) {


$.ajax({ 
        type: 'GET', 
        url: "http://maps.googleapis.com/maps/api/geocode/json?address="+street+",Prishtina&sensor=true", 
        dataType: 'json',
        success: function (data) { 

            $.each(data, function() {
                $.each(this, function(key, value) {
                    switch (key) {

                        case "lat":

                        alert(value) // access to this node works fine                      
                        break;

                        case "lng":

                        alert(value) // access to this node works fine                      
                        break;

                        default: 
                        //window.alert(divid);

                        var myCenter=new 
           google.maps.LatLng(value.geometry.location.lat,value.geometry.location.lng);
                        var mapProp = {
                            center: myCenter,
                            zoom:17,
                            mapTypeId: google.maps.MapTypeId.ROADMAP
                        };

                        var map = new           
                            google.maps.Map(document.getElementById("div-" +  
                            div_id),mapProp);
                        var marker = new google.maps.Marker({
                            position: myCenter,
                            title:'Click to zoom',
                            //icon: 'img/logo3.png'


                        });

                        marker.setMap(map);

        // Zoom to 9 when clicking on marker
        google.maps.event.addListener(marker,'click',function() {
            map.setZoom(9);
            map.setCenter(marker.getPosition());
        });

        break;
           }       
               });
                   });
                   }
                   });

1 个答案:

答案 0 :(得分:1)

使用基于画布的任何内容(几乎所有Google对象都是)。您需要包含excanvas

只需在HTML中的head标记中添加以下内容即可。

<script language="javascript" type="text/javascript" src="Path/to/excanvas.min.js"></script>

只有在IE中加载才能执行以下操作:

<![if !IE]>
    <script language="javascript" type="text/javascript" src="Path/to/excanvas.min.js"></script>
<![endif]>