Last active
December 18, 2015 19:09
-
-
Save eirenik0/5830546 to your computer and use it in GitHub Desktop.
implement the function gmaps_img(points) that returns the google maps image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
# make a basic Point class | |
Point = namedtuple('Point', ["lat", "lon"]) | |
points = [Point(1,2), | |
Point(3,4), | |
Point(5,6)] | |
# implement the function gmaps_img(points) that returns the google maps image | |
# for a map with the points passed in. A example valid response looks like | |
# this: | |
# | |
# http://maps.googleapis.com/maps/api/staticmap?size=380x263&sensor=false&markers=1,2&markers=3,4 | |
# | |
# Note that you should be able to get the first and second part of an individual Point p with | |
# p.lat and p.lon, respectively, based on the above code. For example, points[0].lat would | |
# return 1, while points[2].lon would return 6. | |
GMAPS_URL = "http://maps.googleapis.com/maps/api/staticmap?size=380x263&sensor=false&" | |
def gmaps_img(points): | |
markers = "&".join("markers=%s,%s" % (point.lat, point.lon) for point in points) | |
return GMAPS_URL + markers | |
###Your code here | |
print gmaps_img(points) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I define the namedtuple as 'Point', then pickle is happy: