Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get WiFly API, and use "pygmaps" to show all the hotspot in Google Maps.
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import urllib2
import json
import pygmaps
url = 'http://60.199.253.136/api/action/datastore_search?resource_id=d7a1b4c2-cad0-44f2-958a-a9d7a9330c95&limit=100000'
def main():
content = urllib2.urlopen(url).read()
datas = json.loads(content)['result']['records']
mymap = pygmaps.maps(25.0336, 121.56444, 16)
for counter, item in enumerate(datas):
content = '''
\'<font size=3>\'+
\'Title: %s<br>\'+
\'Name: %s<br>\'+
\'Area: %s<br>\'+
\'AP_ID: %s<br>\'+
\'Address: %s<br>\'+
\'</font>\'
''' % (item['HOTSPOT_TYPE'], item['HOTSPOT_NAME'],
item['AREA'], item['AP_ID'], item['ADDRESS'])
try:
lat = float(item['LAT'])
lng = float(item['LNG'])
except ValueError:
continue
mymap.addpoint(lat, lng, '#0000FF', content)
mymap.draw('./wifly.html')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.