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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置