Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Getting routes from Google Maps for JavaScript

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Code Example
Source file: Media:Rout
Tested with
Devices(s): 3rd Edition devices
Platform(s): Python for s60
S60 3rd Edition (initial release)
Keywords: Python, LBS, Routs, Google Maps
Created: diegodobelo (14/03/2009)
Last edited: hamishwillee (29 Jun 2012)



Location Based Services are one of the most used services in mobile application today. Sometime, routs are needed to determine how to go to a location more easily. This tutorial teaches how to get routs from Google Maps.


This example needs import some modules wich can be encountered File:Rout It also needs internet connection.

Source file

In this example we will get routs from Campina Grande to Joao Pessoa, both cities in Brazil. To get routs for other locations, just alter START_LOCATION and END_LOCATION string constants.

import urllib
from html_parser import *
START_LOCATION = "campina grande"
END_LOCATION = "joao pessoa"
def parser_html(start,end):
rout_link = " \
+ start + \
"&output=mobile&site=local&saddr=" + end + \
GHTML = urllib.urlopen(rout_link)
parser = Rout()
return parser
def get_rout(start, end):
end = end.replace(" ", "+")
start = start.replace(" ", "+")
start = start.encode('utf-8')
end = end.encode('utf-8')
parser = parser_html(start, end)
routlist = parser.return_list()
return routlist
routlist = get_rout(START_LOCATION, END_LOCATION)
for element in routlist:
print unicode(element,'latin-1')
print "Destination does not exist"


If all run ok we will get this result:

Head south on Av. Santa Catarina toward Av. Mato Grosso - 30 m
Turn left at Av. Mato Grosso - 0.2 km
Turn left at Av. Amazonas - 0.2 km
Turn right at Av. Espírito Santo - 1.1 km
Continue on R. Prof. Joaquim F V Galvão - 0.8 km
Turn right at BR-230 - 0.3 km
Slight right to stay on BR-230 - 10.8 km
Continue on BR-101 - 6.9 km
Exit onto BR-230 - 108 km
Continue on Av. Pref. Severino Bezerra Cabral - 2.9 km
Slight left at Av. Canal Go through 1 roundabout - 1.1 km
Make a U-turn at R. Tomaz Soares de Souza - 55 m
This page was last modified on 29 June 2012, at 05:22.
27 page views in the last 30 days.