[web2py] Re: How to use maps in plugin_wiki
Phil, I don't maintain the plugin, but here's what I did to test to see if it would still work. I made copies of all my files (backup). I read the Google developer page that says that now only businesses have to pay for a key. So if you are learning how to use the api you don't have to pay anything now, it is free. I removed the instances or mentions of GOOGLE_KEY in the model file that came with the web2py plugin, and also in the plugin's index file. In my view I added the reference to google's path for the v3 api like this: {{response.files.append(URL('https://maps.googleapis.com/maps/api/js?sensor=false'))}} {{extend 'layout.html'}} {{=LOAD('plugin_gmap')}} then I saved the file. It loaded with no problems. Also, I think the newest version of web2py has more GIS type features built in with examples, but I haven't got the chance yet to try them out. There might be more discussion about this on the list. Good luck! Margaret On Monday, September 17, 2012 2:10:48 AM UTC-5, Philip Kilner wrote: > > Hi, > > I'd like to embed a map in a view, and am trying to use plugin_wiki. > > I have plugin_wiki installed, and when I use a simpler function, like the > YouTube example: - > > {{=plugin_wiki.widget('youtube',code='l7AWnfFRc7g')}} > > > ...all is well. > > However, if I try to embed a map, I get a ticket with: - > > Traceback (most recent call last): > File "/home/philk/web2py/gluon/restricted.py", line 209, in restricted > exec ccode in environment > File "/home/philk/web2py/applications/myapp/views/property/index.html", > line 151, in > AttributeError: 'PluginWiki' object has no attribute 'map' > > Can anyone clue me in as to what I'm missing? > > N.B. I'm new to plugins (most of my apps a re simple CRUD), so I may well > have overlooked something fundamental. > > Also, when I get it working I'm a bit confused about the need for an API > key - the book says "key is the google map api key (default works for > 127.0.0.1)", but first of all I don't see a default key, and secondly I see > from the docs at: - > > https://developers.google.com/maps/signup > > ...that the version that needed an API key is deprecated, so I'm concerned > that the map plugin itself may be updated. > > What would really help me out would be a downloadable app that contained a > worked example, if there is such a thing. > > --- > > Cheers, > > PhilK > > > > > > > > > --
[web2py] Re: How to use maps in plugin_wiki
Hi Margaret, On Monday, 17 September 2012 21:36:47 UTC+1, greaneym wrote: > > Here is a copy of my model, controller and view files where I got it to > work. > Great, thanks - just what I needed. > You need to obtain a key from google because if more than a default number > of people visit your site, you will have to pay them for the use. I forget > what is that specific rule, but you can read their policy. > > This is going to be the sticking point, I think. The issue is that the plugin appears to use the Google Maps v2 API, but this is deprecated and new keys are not available (although existing keys continue to work). -- Cheers, PhilK --
[web2py] Re: How to use maps in plugin_wiki
Phil, That plugin still works. Look in the model file that comes with the plugin. It tells you how to implement the plugin. Here is a copy of my model, controller and view files where I got it to work. You need to obtain a key from google because if more than a default number of people visit your site, you will have to pay them for the use. I forget what is that specific rule, but you can read their policy. I haven't tried the plugin wiki yet, but here is what worked for viewing the map with the plugin. I have a separate model for loading lat, long data. model file: plugin_gmap.py from gluon.storage import Storage plugin_gmap=Storage() plugin_gmap.key='insert_your_string_key_here_from_google' # key for localhost plugin_gmap.set=db(db.capitals.id>0).select() ### change this to a query that lists records with latitude and longitute #for row in plugin_gmap.set: print row.capital_latitude,row.capital_longitude points=db(db.capitals.id>0).select() ### change this to a query that lists records with latitude and longitute #plugin_gmap.represent=lambda row: '%(first_name)s %(last_name)s' % row['auth_user'] plugin_gmap.represent=lambda row: '%(capital_name)s %(capital_latitude)s %(capital_longitude)s ' % row # include plugin in views with {{=LOAD('plugin_gmap')}} controllers: plugin_gmap.py def index(): width = request.vars.width or 400 height = request.vars.height or 300 #rows = plugin_gmap.set.select() rows = db(db.capitals.id>0).select() for row in rows: row.plugin_gmap_popup = plugin_gmap.represent(row) return dict(width=width,height=height,rows=rows,GOOGLEMAP_KEY=plugin_gmap.key) # return DIV(width=width,height=height,rows=rows,GOOGLEMAP_KEY=plugin_gmap.key).xml() idef index(): width = request.vars.width or 400 height = request.vars.height or 300 #rows = plugin_gmap.set.select() rows = db(db.capitals.id>0).select() for row in rows: row.plugin_gmap_popup = plugin_gmap.represent(row) return dict(width=width,height=height,rows=rows,GOOGLEMAP_KEY=plugin_gmap.key) # return DIV(width=width,height=height,rows=rows,GOOGLEMAP_KEY=plugin_gmap.key).xml() in view file just put this line in below the {{extend 'layout.html'}} {{=LOAD('plugin_gmap')}} This combination worked for me. Margaret On Monday, September 17, 2012 2:10:48 AM UTC-5, Philip Kilner wrote: > > Hi, > > I'd like to embed a map in a view, and am trying to use plugin_wiki. > > I have plugin_wiki installed, and when I use a simpler function, like the > YouTube example: - > > {{=plugin_wiki.widget('youtube',code='l7AWnfFRc7g')}} > > > ...all is well. > > However, if I try to embed a map, I get a ticket with: - > > Traceback (most recent call last): > File "/home/philk/web2py/gluon/restricted.py", line 209, in restricted > exec ccode in environment > File "/home/philk/web2py/applications/myapp/views/property/index.html", > line 151, in > AttributeError: 'PluginWiki' object has no attribute 'map' > > Can anyone clue me in as to what I'm missing? > > N.B. I'm new to plugins (most of my apps a re simple CRUD), so I may well > have overlooked something fundamental. > > Also, when I get it working I'm a bit confused about the need for an API > key - the book says "key is the google map api key (default works for > 127.0.0.1)", but first of all I don't see a default key, and secondly I see > from the docs at: - > > https://developers.google.com/maps/signup > > ...that the version that needed an API key is deprecated, so I'm concerned > that the map plugin itself may be updated. > > What would really help me out would be a downloadable app that contained a > worked example, if there is such a thing. > > --- > > Cheers, > > PhilK > > > > > > > > > --
[web2py] Re: How to use maps in plugin_wiki
Hi, Having dug a bit deeper into the options available, it doesn't look like much of a chore to roll my own Google Maps integration. Looking at my choices this one: - http://code.google.com/p/jquery-ui-map/ ...looked promising, but i wondered what others were using? However, I'm now curious about the status of plugin_wiki - I was surprised when I clicked on the link to the Mercurial repository for plugin_wiki to see if I could check out an updated version to be be taken to: - http://code.google.com/p/cube2py/ ...which seems to be an earlier version. Can I ask if there is a more current version of plugin_wiki than that available for download? -- Cheers, PhilK --