DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Google Map Pin

  • submit to reddit
def pin(x,y,char=None):
    # top-left is x-5, y-17
    points = [ (0,0), (-2,-6), (-5,-10), (-5,-14), (-2,-17), \
                      (2,-17), (5,-14), (5,-10), (2,-6)]
    c.polygon([(x+dx,y+dy) for dx,dy in points], 0, (255,119,107), 1)
    if char:
        c.text((x-2, y-7), unicode(char))
        c.point((x,y-12), 0, width=5)
Instead of adding a pin image to the program, this function
will draw a google map pin at point (x,y) instead.
If you give it a char, it will put that char in the middle of 
the pin as well
pin(20,20,'A') # A in the pin
pin(40,40)  # just bull-eye