예제 #1
0
def showmap():

    # Create a map - pymaps allows multiple maps in an object
    tmap = Map()
    tmap.zoom = 3

    # Latitude and lognitude - see the getcords function
    # to see how we convert from traditional D/M/S to the DD type
    # used by Googel Maps

    lat = 0.0
    long = 0.0

    # These coordinates are for Hong Kong
    dlat = "22 15 0 N"
    dlong = "114 10 60 E"

    dlat = dlat.split(" ")
    dlong = dlong.split(" ")

    # Convert the coordinates
    lat = getcords(float(dlat[0]), float(dlat[1]), float(dlat[2]), dlat[3])
    long = getcords(float(dlong[0]), float(dlong[1]), float(dlong[2]),
                    dlong[3])

    # Inserts html into the hover effect
    pointhtml = "Hello!"
    pointicon = Icon()

    # Add the point to the map
    point = (lat, long, pointhtml, pointicon)

    tmap.setpoint(point)
    tmap.center = (1.757537, 144.492188)

    # Put your own googl ekey here
    gmap = PyMap(key="AIzaSyAKoLUaFGp_Eyl9ioFgZ2ARoHBz4nL1PXE", maplist=[tmap])
    gmap.addicon(pointicon)

    # pymapjs exports all the javascript required to build the map!
    mapcode = gmap.pymapjs()

    # Do what you want with it - pass it to the template or print it!
    return mapcode
예제 #2
0
tmap = Map()
tmap.zoom = 3



for row, l in enumerate(reader):
    if row==0:
    #print "\t".join(l)
        pass
    else:
    #print "\t",l[1],l[2]
        pointhtml = l[0]
    point = (l[1], l[2], pointhtml, row)
    tmap.setpoint(point)    

gmap = PyMap(key="ABCDEFG", maplist=[tmap])
#gmap.addicon(icon)

# pymapjs exports all the javascript required to build the map!
mapcode = gmap.pymapjs()
print "<html><head>"
print mapcode
print "</head>"
print """<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 760px; height: 460px"></div> 
</body>
</html>"""from pymaps import Map, PyMap
import csv

reader = csv.reader(open('http://scraperwiki.com/scrapers/export/swimming-attempt/'), delimiter=',', quotechar='"')
예제 #3
0
tmap.zoom = 2

# prepare icons
iconRed = Icon('iconRed')
iconRed.image = "http://labs.google.com/ridefinder/images/mm_20_red.png"
iconRed.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"
iconBlue = Icon('iconBlue')
iconBlue.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png"
iconBlue.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"
iconGreen = Icon('iconGreen')
iconGreen.image = "http://labs.google.com/ridefinder/images/mm_20_green.png"
iconGreen.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"
iconYellow = Icon('iconYellow')
iconYellow.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png"
iconYellow.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"

# create points
for x, row in data.T.iteritems():
    icon = iconRed.id
    point = (row['Lat'], row['Long'], text, icon)
    tmap.setpoint(point)

# create googlemap
gmap = PyMap(key='XXXXXXXXXXXXXXXXXX', maplist=[tmap])
gmap.addicon(iconGreen)
gmap.addicon(iconYellow)
gmap.addicon(iconBlue)
gmap.addicon(iconRed)

# output
open('Data.html', 'wb').write(gmap.showhtml())