Friday, November 19, 2010

Real-Time German Buses Map

Real-Time Reutlingen Buses Map

This real-time Goggle Map shows the current location of every bus in the German city of Reutlingen.

The map shows the city's bus routes with coloured polylines. The location of each bus-stop on each line is also clearly shown. The location of all buses on the network is shown in real-time with animated bus icons. If you click on any of the bus icons you can receive information about the bus' number and its current destination.

In the future the developer plans to add a real-time traffic overlay and live tracking of regional trains.

________________

Labels:

Fusion Tables

Spatial Queries

The spatial queries that were recently added to Fusion Tables mean that it is now very easy to create a very powerful Store Locator using just Google Maps and Fusion Tables. If you have a Fusion Table that contains your store data you can easily create a Google Map that will load the stores within a defined area or load the nearest stores to a given location.

Using the bounding box spatial query you can load points within a predefined area. You can also use the 'distance' query to load the stores nearest to a given point.

Load Nearest Points

We can use the getCenter function to get the latitude and longitude at the centre of the map. It is then possible to load the nearest points of interest in our Fusion Table to this point. The following function will load the ten nearest points to the current centre of the map.

function loadNearest() {
layer.setQuery("SELECT Country FROM 188044 ORDER BY ST_DISTANCE(Country, LATLNG( " + map.getCenter().lat() +', '+ map.getCenter().lng() + ")) LIMIT 10");
}

We can then add a button to the map to call the function with

onclick="loadNearest()"

Bounding Box

It is now also possible to easily create a bounding box with Fusion Tables. Using a bounding box we can define an area on the map and load in all the points from a Fusion Table that fall within that area.

function boundingBox() {
layer.setQuery("SELECT Country FROM 188044 WHERE ST_INTERSECTS(Country, RECTANGLE(LATLNG(35.77, -12.57), LATLNG(66.6, 37.3)))");
}

We can add a button to the map to call the bounding box with:

onclick="boundingBox()"

This Spatial Queries demo shows the bounding box in action. To add the 'ditance' query just add the code I have outlined above.