2013-04-25 65 views
0

我將我的代碼版本2版本3.我收到腳本錯誤在 http://maps.gstatic.com/intl/en_us/mapfiles/api-3/12/9/main.js 我的代碼在頁面上作爲轉換谷歌地圖API V2至V3獲得在main.js腳本錯誤

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&key=<%=strGk%>"></script> 
    <script type="text/javascript"> 
function initialize() { 
      var myOptions = { 
      zoom: 7, 
      mapTypeId: google.maps.MapTypeId.ROADMAP, 
      center: "<%=strOrig%>", 
      mapTypeControl: true, 
      mapTypeControlOptions: { 
       style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, 
       position: google.maps.ControlPosition.BOTTOM 
      }, 
      navigationControl: true, 
      navigationControlOptions: { 
       style: google.maps.NavigationControlStyle.ZOOM_PAN, 
       position: google.maps.ControlPosition.TOP_RIGHT 
      }, 
      scaleControl: true, 
      scaleControlOptions: { 
       position: google.maps.ControlPosition.TOP_LEFT 
      } 
     } 

     map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
     directionsDisplay.setMap(map); 
     directionsDisplay.setPanel(document.getElementById("directions")); 
     google.maps.event.addListener(directionsDisplay, "addoverlay", afterDir); 
     google.maps.event.addListener(directionsDisplay, "error", handleErrors); 
     // geocoder = new GClientGeocoder(); 
     geocoder = new google.maps.Geocoder();  
+0

有什麼錯誤?也有助於添加所有的JS代碼;你已經通過初始化函數部分截斷了它 – duncan 2013-04-25 12:39:42

回答

0

您正在使用過時的過時導航控制

在V3它分爲單獨的縮放和平移控制。見documentation

TRY

function initialize() { 
    var mapOptions = { 
    zoom: 7, 
    center: new google.maps.LatLng(55.91913101970850, -4.650520), 
    mapTypeId: google.maps.MapTypeId.ROADMAP, 
    mapTypeControl: true, 
    mapTypeControlOptions: { 
     style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, 
     position: google.maps.ControlPosition.BOTTOM 
    }, 
    panControl: true, 
    panControlOptions: { 
     position: google.maps.ControlPosition.TOP_RIGHT 
    }, 
    zoomControl: true, 
    zoomControlOptions: { 
     //style: google.maps.ZoomControlStyle.LARGE, 
     position: google.maps.ControlPosition.TOP_RIGHT 
    }, 
    scaleControl: true, 
    scaleControlOptions: { 
     position: google.maps.ControlPosition.TOP_LEFT 
    }, 
    } 
    var map = new google.maps.Map(document.getElementById('map_canvas'), 
           mapOptions); 
}