08f2a7bc833477a6334aac732ba2413aba7a4d60
[myslice.git] / plugins / googlemap / __init__.py
1 from unfold.plugin import Plugin
2
3 class GoogleMap (Plugin):
4
5     # expcted input are
6     # query :           query about the slice 
7     # query_all :       query about all resources
8     # googlemap_key :   mandatory googlemap API v3 key
9     # latitude,longitude, zoom : the starting point
10     # apparently at some point there has been support for a boolean 'checkboxes' input arg but seems dropped
11     def __init__ (self, query, googlemap_api_key=None, latitude=43., longitude=7., zoom=4, **settings):
12         Plugin.__init__ (self, **settings)
13         self.query=query
14         self.googlemap_api_key=googlemap_api_key
15         self.latitude=latitude
16         self.longitude=longitude
17         self.zoom=zoom
18
19     def template_file (self):
20         return "googlemap.html"
21
22     def template_env (self, request):
23         env={}
24         return env
25
26     def requirements (self):
27         googlemap_api_url = "https://maps.googleapis.com/maps/api/js?"
28         if self.googlemap_api_key: googlemap_api_url+="key=%s&"%self.googlemap_api_key
29         googlemap_api_url += "sensor=false"
30         reqs = {
31             # let users configure their googlemap API key in production deployements
32             'js_files' : [ googlemap_api_url,
33                            "/js/googlemap.js",
34                            "/js/markerclusterer.js",
35                             "js/manifold.js", "js/manifold-query.js", 
36                             "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", 
37                             "js/unfold-helper.js",
38                            ],
39             'css_files' : [ "css/googlemap.css",
40                             ],
41             }
42         return reqs
43
44     # the list of things passed to the js plugin
45     def json_settings_list (self): 
46         return [ 'plugin_uuid', 'query_uuid',
47                  'init_key',
48                  'latitude', 'longitude', 'zoom', 
49                  ]