Real time Google Map

2020-02-24 03:57发布

Hello Google map API experts, What would be the best(good) way to develop a real time dynamic map using Google Map API.

Example: http://whrrl.com/

It would be really helpful if someone points me towards the right direction. Thank you

4条回答
够拽才男人
2楼-- · 2020-02-24 04:30

I found the easiest solution to this.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-02-24 04:31

Just to add another example for you to check out, here is the source code for a live map showing the position of trains on the London Underground. The site can be found at http://traintimes.org.uk:81/map/tube/?from=map;to=tube, although unfortunately it is no longer active as Transport for London has suspended their API service due to high demand. Hopefully you might be able to get an idea from the source code though about how to develop a dynamic, real-time map.

查看更多
在下西门庆
4楼-- · 2020-02-24 04:48

Best place to start is the Google Maps Javascript API. Here is the documentation.

You will find lots of sample there, but basically with a few lines of javascript you can associate a Google Maps object with an element in the DOM (map_canvas):

var latlng = new google.maps.LatLng(-34.397, 150.644);

var myOptions = {
  zoom: 8,
  center: latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

Having a look at what Whrrl is doing specifically. They are updating their map center (and displaying a custom popup) based on a pre-rendered set of users in the their system (If you view the source for their home page, you can see the big chunk of user JSON at the bottom of the file). This javascript fires events on a timer panning the map from one location to the next.

查看更多
手持菜刀,她持情操
5楼-- · 2020-02-24 04:51

AJAX calls or Comet, to fetch/be notified of new map data coming through.

Take a look at node.js :)

查看更多
登录 后发表回答