Skip to content

Commit

Permalink
add language support
Browse files Browse the repository at this point in the history
  • Loading branch information
Рубцов Дмитрий committed Aug 17, 2015
1 parent 24b8aa2 commit 077b31d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions motionless.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Map(object):
MAX_Y = 640
ZOOM_RANGE = range(1, 21)

def __init__(self, size_x, size_y, maptype, zoom=None):
def __init__(self, size_x, size_y, maptype, zoom=None, language='en'):

self.base_url = 'http://maps.google.com/maps/api/staticmap?'
self.size_x = size_x
Expand All @@ -101,6 +101,7 @@ def __init__(self, size_x, size_y, maptype, zoom=None):
self.format = 'png'
self.maptype = maptype
self.zoom = zoom
self.language = language

def __str__(self):
return self.generate_url()
Expand Down Expand Up @@ -163,15 +164,16 @@ def check_parameters(self):

def generate_url(self):
self.check_parameters()
url = "%smaptype=%s&format=%s&center=%s&zoom=%s&size=%sx%s&sensor=%s" % (
url = "%smaptype=%s&format=%s&center=%s&zoom=%s&size=%sx%s&sensor=%s&language=%s" % (
self.base_url,
self.maptype,
self.format,
self.center,
self.zoom,
self.size_x,
self.size_y,
self._get_sensor())
self._get_sensor(),
self.language)

self._check_url(url)
return url
Expand All @@ -191,14 +193,15 @@ def add_latlon(self, lat, lon):

def generate_url(self):
self.check_parameters()
url = "%smaptype=%s&format=%s&size=%sx%s&sensor=%s&visible=%s" % (
url = "%smaptype=%s&format=%s&size=%sx%s&sensor=%s&visible=%s&language=%s" % (
self.base_url,
self.maptype,
self.format,
self.size_x,
self.size_y,
self._get_sensor(),
"|".join(self.locations))
"|".join(self.locations),
self.language)

self._check_url(url)
return url
Expand Down Expand Up @@ -313,13 +316,14 @@ def add_path_latlon(self, lat, lon):

def generate_url(self):
self.check_parameters()
url = "%smaptype=%s&format=%s&size=%sx%s&sensor=%s" % (
url = "%smaptype=%s&format=%s&size=%sx%s&sensor=%s&language=%s" % (
self.base_url,
self.maptype,
self.format,
self.size_x,
self.size_y,
self._get_sensor())
self._get_sensor(),
self.language)

if self.center:
url = "%s&center=%s" % (url, self.center)
Expand Down

0 comments on commit 077b31d

Please sign in to comment.