在谷歌地图实时跟踪 [英] Real time tracking in google map

查看:141
本文介绍了在谷歌地图实时跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我不知道如何显示真实的图片。我已经写了一个Android应用程序上传经纬度和长期的MySQL数据库(每2分钟上传)。在网站(php,javascript,html)
的谷歌地图中的实时位置,这意味着如何每2分钟动态更新Google地图标记[从MySQL数据库
获取最后两分钟记录并显示标记(更新或消失)]

我可以点击标记以显示信息[从mysql数据库获取(不重要,因为它与静态Google地图相同!?]

就像这样: http:// traintimes.org.uk/map/tube/



我刚刚知道如何做,当我刚刚获得1次(静态Google地图!?)与我有限的知识。

我已经在堆栈溢出和谷歌
中搜索相同的问题,但我很抱歉,我仍然不知道如何去做,因为我的愚蠢。 / p>

实时Google地图



任何人都可以给我一些教程网站或建议吗? p>

最后,感谢你们所有人

我仍​​是一名英语学习者,对于任何错误的语法我都很抱歉。

解决方案

在地图上实时跟踪地理纬度/经度



您正在寻找更新在更新发生时实时协调地图上的实体(纬度/经度位置)(谷歌地图或其他)。这里有一篇博客文章可能会让你开始朝着正确的方向发展: http://blog.pubnub.com/streaming-geo-coordinates-from-mongodb-to-your-iphone-app-with-pubnub-using- websocket-sdk / - 它使用MongoDB和Ruby而不是PHP和MySQL。但是,在这种情况下,使用PHP和MySQL中的实时地图在HTML页面中设置事物并且使用以下详细信息很容易。还有一个视频: https://vimeo.com/60716860



使用MySQL实时触发更新



首先,您需要使用MySQL触发器来推动Lat / Long坐标 - <当mysql发生变化时调用推送器 - 此用法MySQL触发器



或者,您可能希望直接使用PHP来使用PHP推送SDK调用推送信号,如下所示:

  $ pubnub-> publish(array(
'channel'=>'live_map_coords',
'message'=> array (12.3482,8.3344)
));



在JavaScript中接收推送消息并在地图上显示更新



 < script src = // pubnub.a.ssl.fastly.net/pubnub-3.4.5.min.js></script> 
< script>(function(){

PUBNUB.init({
subscribe_key:'demo'
})。subscribe({
channel :'live_map_coords',
callback:function(lat_lon){alert(lat_lon)}
});

})();< / script>

一旦您拥有 map.html 页面使用上面的代码,您可以在地图上使用绘图坐标更改警报(lat_log)消息弹出窗口。下面是使用 D3 JavaScript SVG渲染框架完整工作图绘制示例框架: https://github.com/stephenlb/pubnub-mongo-pipe/blob/master/phone/map.html


注意:这仅仅是一个起点,为您提供参考资料,让您能够轻松简单,您可以将您的应用程序指向您的方向。




下一步将实时地理地图拼凑在一起



您将接下来要完成此过程,并将此处列出的所有单独组件合并到一起。


  1. 修改 map.html 页面以达到您的目的,以显示始终可见的点。请注意,在视频中,点是临时显示并快速消失的灯塔。你会想让他们坚持在地图上。这基本上就是让它看起来像你想要的样子步骤。

  2. 决定如何以及何时从PHP触发TCP套接字推送事件或MySQL直接。 我推荐PHP方式


I already wrote a android apps to upload the lat and long to MySQL database(upload every 2min).

now, i am no idea how to show the real time location in Google map in the website(php,javascript,html) which mean how to dynamic update the Google map markers every 2 min [get the last two minutes records from MySQL database and show the markers(update or disappear)]

and i can click the marker to show the info[get from mysql database(not important point because it same with static Google map!?]

just like this: http://traintimes.org.uk/map/tube/

I just know how to do when i just get 1 time (Static Google map!?) with my limited knowledge.

I already search same question in stack overflow and google but i am sorry i still no idea how to do it because of my stupid.

Real time Google Map

anyone could give me some tutorial website or suggestion?

At last, thank all of you and I still a learner of English,I am sorry about any wrong grammar.

解决方案

Real-time Tracking Geo Latitude/Longitude on a Map

You are looking to update coordinate entities (lat/lon position) on a map (google maps or otherwise) in real-time as the updates occur. Here is a blog post that may get you started in the right direction: http://blog.pubnub.com/streaming-geo-coordinates-from-mongodb-to-your-iphone-app-with-pubnub-using-websocket-sdk/ - this uses MongoDB and Ruby rather than PHP and MySQL. However it will be easy to get things setup in this case with a real-time map in PHP and MySQL on an HTML page with the following details. And there is a video too: https://vimeo.com/60716860

Using MySQL to Trigger Update in Real-time

First you'll want to use either MySQL triggers to push the Lat/Long coords - Invoke pusher when mysql has changed - this uses MySQL Triggers

Or as an alternative you may want to use PHP directly to invoke the push signal using a PHP push SDK as follows: https://github.com/pubnub/php#php-push-api

$pubnub->publish(array(
    'channel' => 'live_map_coords',
    'message' => array( 12.3482, 8.3344 )
));

Receiving The Push Message in JavaScript and Showing the Updates on a Map

<script src=//pubnub.a.ssl.fastly.net/pubnub-3.4.5.min.js></script>
<script>(function(){

    PUBNUB.init({
        subscribe_key : 'demo'
    }).subscribe({
        channel  : 'live_map_coords',
        callback : function(lat_lon) { alert(lat_lon) }
    });

})();</script>

Once you have an map.html page with the above code in it, you can change the alert(lat_log) message popup with drawing coords on a map. Here is a fully working map drawn example using D3 JavaScript SVG rendering Framework: https://github.com/stephenlb/pubnub-mongo-pipe/blob/master/phone/map.html

NOTE: This is only a starting point and provides you with references on getting started to make it easy and simple, yet flexible based on the direction you will be taking your app.

Next Steps to Piece Together the Real-time Geo Map

You will next want to do the following to complete the process and join together all the separate components listed here.

  1. Modify the map.html page for your purposes to display always-visible dots. Note that in the video the dots are temporary beacons that display and vanish rapidly. You'll want to make them persist on the map. This is basically the "Make it look the way you want it" step.
  2. Decide how and when you want to trigger the TCP Socket Push events from PHP or MySQL directly. I'd recommend the PHP approach.

这篇关于在谷歌地图实时跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆