這個問題來自Griffiths的Head First C書。從第p頁開始。本書指導如何開發將由地圖應用程序在網站http://oreillyhfc.appspot.com/map.html上閱讀的JSON文件。從包含經緯度值的文件開始,開發一個C程序將其轉換爲JSON文件。到目前爲止,儘管我懷疑生成的輸出文件是否符合JSON文件的標準,但由於缺乏知識,所以一切工作都很完美。Head First C Google地圖與JSON文件關聯
問題在上一步之後開始。首先,當我嘗試整體保存網頁時(Chrome,Firefox在Ubuntu 12.04.3 32位和Windows 7 64位上),map.html文件的本地副本毫無用處。當文件被雙擊時,一個白色的空白頁面顯示,沒有地圖可見。但是,當使用唯一的html文件選項保存時,會顯示地圖,但程序不會讀取同一目錄中的JSON文件以顯示相應的紅色標記。這背後的原因是什麼,我該如何糾正這種情況?它近來一直在困擾着我。
在此先感謝
相應的文件
「output.json」
data=[
{latitude: 42.363400, longitude: -71.098465, info: 'Speed = 21'},
{latitude: 42.363327, longitude: -71.097588, info: 'Speed = 23'},
{latitude: 42.363255, longitude: -71.096710, info: 'Speed = 17'},
{latitude: 42.363182, longitude: -71.095833, info: 'Speed = 22'},
{latitude: 42.363110, longitude: -71.094955, info: 'Speed = 14'},
{latitude: 42.363037, longitude: -71.094078, info: 'Speed = 16'},
{latitude: 42.362965, longitude: -71.093201, info: 'Speed = 18'},
{latitude: 42.362892, longitude: -71.092323, info: 'Speed = 22'},
{latitude: 42.362820, longitude: -71.091446, info: 'Speed = 17'},
{latitude: 42.362747, longitude: -71.090569, info: 'Speed = 23'},
{latitude: 42.362675, longitude: -71.089691, info: 'Speed = 14'},
{latitude: 42.362602, longitude: -71.088814, info: 'Speed = 19'},
{latitude: 42.362530, longitude: -71.087936, info: 'Speed = 16'},
{latitude: 42.362457, longitude: -71.087059, info: 'Speed = 16'},
{latitude: 42.362385, longitude: -71.086182, info: 'Speed = 21'}
]
「gpsdata.csv」
42.363400,-71.098465,Speed = 21
42.363327,-71.097588,Speed = 23
42.363255,-71.096710,Speed = 17
42.363182,-71.095833,Speed = 22
42.363110,-71.094955,Speed = 14
42.363037,-71.094078,Speed = 16
42.362965,-71.093201,Speed = 18
42.362892,-71.092323,Speed = 22
42.362820,-71.091446,Speed = 17
42.362747,-71.090569,Speed = 23
42.362675,-71.089691,Speed = 14
42.362602,-71.088814,Speed = 19
42.362530,-71.087936,Speed = 16
42.362457,-71.087059,Speed = 16
42.362385,-71.086182,Speed = 21
附:我完全按照書中講過的那樣完成,而且我對JS很不熟悉。
我會盡我所能,當我有時間謝謝你的答案。我認爲它適合你。 – Vesnog
是的,我再次看到它。你有WAMP服務器打開map.HTML。而改變輸入文件即spooky.CSV只是改變緯度經度..保留1的差別..書房可以看到緯度經度清楚烏爾。並放大它播放它 – akkimads