2014-09-04 114 views
0

我正在建立一個谷歌地圖頁面,其行爲有點像全國各地的4或5個GPS設備的數據庫。我正在使用的gps設備將在他們將要連接的路由器中擁有自己的ip地址。要訪問您要輸入的格位,請輸入:10.10.10.222/server/latitude.cgi並且該文件只能訪問文件的文本。我的問題是,我不知道如何將它應用到谷歌地圖JavaScript中,它只是自動讀取文件中的文本,或者我必須指定它來讀取文本?我無法測試它幾天,而不是陷入困境我想在這裏問身份證。使用JavaScript在谷歌地圖上的GPS座標

描述GPS設備的頁面是here,與信息是如何從它拉,如何調用它一起。

這裏是我的javascript與lattitude和經度佔位符(47,-100):

{ 
    var map = new google.maps.Map(map_canvas, map_options); 
    var point = new google.maps.LatLng(47, -100); 
    var marker = new google.maps.Marker({ 
     position: point, 
     map: map, 
     icon: 'PointMarkerON.png', 
     title: 'Site 1' 

    })} 
} 

回答

1

你必須調用谷歌地圖的API。有關例子之前,請求GPS URL,如果jQuery是有:

$.get("http://10.10.10.222/server/latitude.cgi", function(latitude) { 
    $.get("http://10.10.10.222/server/longitude.cgi", function(longitude) { 

     var map = new google.maps.Map(map_canvas, map_options); 
     var point = new google.maps.LatLng(latitude, longitude); 
     var marker = new google.maps.Marker({ 
      position: point, 
      map: map, 
      icon: 'PointMarkerON.png', 
      title: 'Site 1' 
     }); 
    }); 
}); 
+0

非常感謝! – user3479343 2014-09-08 17:40:01