def test_Map(self): map = Map() self.assertIs(map, Map) map = Map(filename=self.tmpfile.name) self.assertIs(map, Map) # add_marker self.assertRaises(ValueError, lambda: map.add_marker(Search( 'New York City'))) map.add_marker(Spot.from_search(Search('New York City'))) map.save_map_file() # spots self.assertIs(map.spots, list) self.failUnlessRaises( AttributeError, setattr, map, "spots", "set not allowed") # filename self.assertIs(map.filename, str) map.filename = 'filename' self.assertStrEqual(map.filename, 'filename')
def generate_map( spots, map=None, size=None, type=None, path=False, region=False, filename=None): labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' size_x, size_y = size.split('x') geomap = Map( size_x=int(size_x), size_y=int(size_y), maptype=type, region=region, fillcolor='gray') max_index = (len(spots) - 1) if path is True: for index, spot in enumerate(spots): geomap.add_marker(spot, label=labels[index]) geomap.add_path_latlon(str(spot.latitude), str(spot.longitude)) if region is True: for index, spot in enumerate(spots): geomap.add_path_latlon(str(spot.latitude), str(spot.longitude)) if index == max_index: geomap.add_path_latlon( str(spots[0].latitude), str(spots[0].longitude)) else: for index, spot in enumerate(spots): geomap.add_marker(spot, label=labels[index]) if filename is not None: geomap.filename = filename geomap.save_map_file() else: print geomap.generate_url()