1. yourkin
  2. yandex-maps

Commits

Mikhail Korobov  committed fd6357b

Авто-преобразование типов при необходимости

  • Participants
  • Parent commits 5a78de3
  • Branches default

Comments (0)

Files changed (3)

File README.rst

View file
     >>> print pos
     (u'30.271446', u'59.903300')
 
-    >>> api.get_map_url(api_key, float(pos[0]), float(pos[1]), 13, 200, 300)
+    >>> api.get_map_url(api_key, pos[0], pos[1], 13, 200, 300)
     http://static-maps.yandex.ru/1.x/?ll=30.2714460,59.9033000&size=200,300&z=12&l=map&pt=30.2714460,59.9033000&key=my_api_key
 
 

File yandex_maps/api.py

View file
 def get_map_url(api_key, longtitude, latitude, zoom, width, height):
     ''' returns URL of static yandex map '''
     params = [
-       'll=%0.7f,%0.7f' % (longtitude, latitude,),
+       'll=%0.7f,%0.7f' % (float(longtitude), float(latitude),),
        'size=%d,%d' % (width, height,),
        'z=%d' % zoom,
        'l=map',
-       'pt=%0.7f,%0.7f' % (longtitude, latitude,),
+       'pt=%0.7f,%0.7f' % (float(longtitude), float(latitude),),
        'key=%s' % api_key
     ]
     return STATIC_MAPS_URL + '&'.join(params)

File yandex_maps/tests.py

View file
 
 class MapUrlTest(TestCase):
     def test_map_url(self):
-        url = get_map_url(TEST_API_KEY, float(COORDS[0]), float(COORDS[1]), 5, 200, 300)
+        url = get_map_url(TEST_API_KEY, COORDS[0], COORDS[1], 5, 200, 300)
         self.assertEqual(url, MAP_URL)