dongsha2792 2014-09-04 21:51
浏览 85
已采纳

使用JavaScript在Google地图上进行GPS坐标

I'm building a google map page that will act somewhat like a database for 4 or 5 gps devices around the country. the gps devices that i am using will have their own ip address within a router they will be connected to. to access the lattitude you would input EXAMPLE: 10.10.10.222/server/latitude.cgi and that would access a file with just the text of the lattitude. My problem is that i don't know how to apply that into a google map javascript, does it just reads the text in the file automatically or i have to assign it to read the text? i can't test it for a few days so rather than get bogged down i figured id ask here.

The page describing the gps devices is here, along with how the information is pulled from it and how to call it.

here is my javascript with lattitude and longitude placeholders of (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条回答 默认 最新

  • dongqiao3833 2014-09-05 11:48
    关注

    You have to request gps url before calling Google Maps API.For example, if jquery is there :

    $.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'
            });
        }); 
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染