File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 9
9
"""
10
10
11
11
from __future__ import unicode_literals
12
-
12
+ import numbers
13
13
import json
14
14
from collections import OrderedDict
15
15
@@ -297,6 +297,26 @@ def render(self, **kwargs):
297
297
'</style>' ), name = 'map_style' )
298
298
299
299
super (LegacyMap , self ).render (** kwargs )
300
+
301
+ @property
302
+ def location (self ):
303
+ return self ._location
304
+
305
+ @location .setter
306
+ def location (self , value ):
307
+ """Validates the location values before setting"""
308
+ if type (value ) not in [list , tuple ]:
309
+ raise TypeError ("Location is not a list, expecting ex: location=[45.523, -122.675]" )
310
+
311
+ if len (value ) != 2 :
312
+ raise ValueError ("Location should have two values, [lat, lon]" )
313
+
314
+ for val in value :
315
+ if not isinstance (val , numbers .Rational ):
316
+ raise TypeError ("Location values should be numeric, {val} is not a number" .format (val ))
317
+
318
+
319
+ self ._location = value
300
320
301
321
302
322
class GlobalSwitches (Element ):
You can’t perform that action at this time.
0 commit comments