1 from unfold.plugin import Plugin
3 class GoogleMap (Plugin):
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, query_all, googlemap_api_key=None, latitude=43., longitude=7., zoom=4, **settings):
12 Plugin.__init__ (self, **settings)
14 self.query_all = query_all
15 self.googlemap_api_key=googlemap_api_key
16 self.query_all_uuid = query_all.query_uuid if query_all else None
17 self.latitude=latitude
18 self.longitude=longitude
21 def template_file (self):
22 return "googlemap.html"
24 def template_env (self, request):
28 def requirements (self):
29 googlemap_api_url = "https://maps.googleapis.com/maps/api/js?"
30 if self.googlemap_api_key: googlemap_api_url+="key=%s&"%self.googlemap_api_key
31 googlemap_api_url += "sensor=false"
33 # let users configure their googlemap API key in production deployements
34 'js_files' : [ googlemap_api_url,
36 "/js/markerclusterer.js",
37 "js/manifold.js", "js/manifold-query.js",
38 "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js",
39 "js/unfold-helper.js",
41 'css_files' : [ "css/googlemap.css",
46 # the list of things passed to the js plugin
47 def json_settings_list (self):
48 return [ 'plugin_uuid', 'query_uuid', 'query_all_uuid',
50 'latitude', 'longitude', 'zoom',