2014-01-17 90 views
0

我按照這個教程:http://www.youtube.com/watch?v=7mkOVjRz3tg 但是從我的數據庫中獲取信息,而我的地圖只是以沒有地圖的白色屏幕出現。 我有一個Android應用程序運行,但後來我有太多的點來繪製android應用程序停止工作,所以我試圖使它成爲一個web界面。任何幫助,將不勝感激。另外這是我第一次與js 處理的JSON的一個片段是這樣的:谷歌地圖api v3在繪製標記時不出現

{ 
    "coords": [ 
    { 
     "latitude": "33.702908", 
     "longitude": "-86.370771", 
     "id": "" 
    }, 
    { 
     "latitude": 0, 
     "longitude": 0, 
     "id": "(null)" 
    }, 
    { 
     "latitude": "0.000000", 
     "longitude": "0.000000", 
     "id": "00004561-CE13-4125-A244-989D2E984A91" 
    }, 
    { 
     "latitude": "33.273388", 
     "longitude": "-86.832977", 
     "id": "0000F355-43B0-4164-9CD4-0D7C57A1B37C" 
    } 
    ] 
} 

HTML + JS

<!DOCTYPE html> 
<html> 
<head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="utf-8"> 
    <title>Simple markers</title> 
    <style> 
    html, body, #map-canvas { 
    height: 100%; 
    width: 100%; 
    margin: 0px; 
    padding: 0px 
    } 
    </style> 
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 
    <script src="jquery-1.10.2.min.js"></script> 

    <script > 

function getUserLocs(callback){ 
    $.getJSON('http://www.url.com', callback) 
} 

    function initialize() { 
    var myLatlng = new google.maps.LatLng(-25.363882,131.044922); 
    var mapOptions = { 
     zoom: 4, 
     center: myLatlng 
    } 
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); 

    var marker = new google.maps.Marker({ 
     position: myLatlng, 
     map: map, 
     title: 'H' 
    }); 

    getUserLocs(function(data){ 
     var locs = data.coords; 
     for (i in locs) { 
     var lat = locs[i]; 
     var lon = locs[i]; 
     latLng = new google.maps.LatLng(lat, lon); 

     var marker = new google.maps.Marker({ 
     position: latLng, 
     map: map, 
     title: 'H' 

     }); 

    }) LINE 51 this where the syntax error is 
    } 


    </script> 
    <script> 
    google.maps.event.addDomListener(window, 'load', initialize); 

    </script> 
</head> 
<body> 
    <div id="map-canvas"></div> 
</body> 
</html> 

錯誤:語法錯誤:語法錯誤map.html:51

+0

在控制檯的任何消息? –

+0

只是將錯誤放在問題的底部 –

+0

您是否在