def get_map(self): """Displays a google map oO""" tmap = Map() tmap.zoom = 12 # San Francisco top_left = (37.793508, -122.511978) bottom_right = (37.742485, -122.369156) tmap.center = ((top_left[0] + bottom_right[0]) / 2, (top_left[1] + bottom_right[1]) / 2) pin_icon = Icon(id='pin', image="http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png" ) for gps in self.application.pins: point = (gps[0], gps[1], 'derp', pin_icon.id) tmap.setpoint(point) for gps in self.application.hotspots: point = (gps[0], gps[1], 'derp') tmap.setpoint(point) gmap = PyMap(key='AIzaSyA59m0VtN62qf7Gu_c-_PSX_Eiw_t2vzBA', maplist=[tmap]) gmap.addicon(pin_icon) mapcode = gmap.showhtml() return mapcode
def showmap(lat, lng): from pymaps import Map, PyMap, Icon # import the libraries # 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]) # lng = getcords(float(dlong[0]), float(dlong[1]), float(dlong[2]), dlong[3]) # Inserts html into the hover effect pointhtml = "Hello!" # Add the point to the map icon = Icon() point = (lat, lng, pointhtml, icon.id) tmap.setpoint(point) tmap.center = (1.757537, 144.492188) # Put your own googl ekey here GOOGLE_KEY = 0 gmap = PyMap(key=GOOGLE_KEY, maplist=[tmap]) gmap.addicon(icon) # 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
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
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
def show_map(bcity): """Shows a map in your default browser with sites marked""" print('\n---> Gerar Visualizacao Grafica dos Scores obtidos por Site de Localizacao\n') zoom=int(eval(input('Zoom(4):'))) tmap = PyMap() tmap.maps[0].center = (46.0000,7.0000) tmap.key='AIzaSyCj-UAqhnY-fhkeCEayjALakrGJMgcaQ6A' tmap.maps[0].zoom = zoom blue_icon = Icon('blue_icon') blue_icon.image = "http://www.clker.com/cliparts/B/B/1/E/y/r/marker-pin-google-md.png" blue_icon.iconSize = (15,25) tmap.addicon(blue_icon) red_icon = Icon('red_icon') red_icon.image = "http://www.clker.com/cliparts/e/3/F/I/0/A/google-maps-marker-for-residencelamontagne-md.png" red_icon.iconSize = (15,25) tmap.addicon(red_icon) file=open('coords.csv','r') reader=csv.reader(file) for row in reader: if row[0]==bcity: p=[row[1],row[2],row[0][3:],'blue_icon'] tmap.maps[0].setpoint(p) else: p=[row[1],row[2],row[0][3:],'red_icon'] tmap.maps[0].setpoint(p) file.close() open('mymap.html','w').write(tmap.showhtml()) filepath = os.path.abspath('mymap.html') webbrowser.open('file://' + filepath) return '\nMapa guardado!'
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='"')
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())