2013-02-21 93 views
12

我發展與VB.NET和谷歌地圖3.0版應用程序,並試圖建立一個地圖這些屬性:遺漏的類型錯誤:無法讀取的特性「__e3_」未定義

<script type="text/javascript"> 
    $(document).ready(function(){ 
     var sPath ="images/AppIcons/Vehicles/icon05.png,"; 
     var markers= new google.maps.Marker({ 
      position : new google.maps.LatLng(4.759915, -74.04083), 
      map : map, 
      icon : new google.maps.MarkerImage(+ sPath + null, null, null, new google.maps.Size(32, 32)), 
      animation: google.maps.Animation.DROP, 
      title : "buena" 
     }); 
     var myLatlng = new google.maps.LatLng(0, 0); 
     var mapOptions={zoom: 3,center: new google.maps.LatLng(4.590798,-74.084244),mapTypeId: google.maps.MapTypeId.ROADMAP }; 
     var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); 
     var marker = setMarkers(map); 
     var infowindow = new google.maps.InfoWindow({Content : '<b>FM3200 - FM3200</b><div><font size=1>&nbsp;</font></div><div><u>20/01/2013 04:30:56 p.m. - Voltaje Externo - (Norte)</u></div>Ubicacion Invalida In1:0 In2:0 In3:0 Batext:4.45V Vel:0 Odom:0 Ibutton:0 Oficina Principal Risk, Kmh: 0'}); 
     if (markers !='') { 
      google.maps.event.addListener(marker, 'click', function() { 
       infowindow.open(map,marker); 
       /*if (marker.getAnimation() != null) { 
        marker.setAnimation(null); 
       } else { 
        marker.setAnimation(google.maps.Animation.BOUNCE); 
       }*/ 
      }); 
     } 
    }); 
    function setMarkers(map,markers) { 
     var marker =markers; 
     if (marker !='') { 
      return marker; 
     } 
    }</script> 

當我運行此代碼,出現此錯誤消息:

Uncaught TypeError: Cannot read property '__e3_' of undefined main.js:18 

如何解決此錯誤?

+0

你的功能setMarkers()不創建適當的標記對象。 – Marcelo 2013-02-21 17:31:44

+0

也許使用[onload event](http://stackoverflow.com/questions/3698200/window-onload-vs-document-ready)而不是ready事件 – geocodezip 2013-02-21 18:06:36

回答

15

將創建的map移動到該函數的頂部。

目前使用map作爲map -option爲markers,在那裏它有望成爲google.maps.Map -instance(但它是不確定的,因爲地圖尚未創建)