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, googlemap_api_key=None, latitude=50., longitude=50, zoom=3, **settings):
12 Plugin.__init__ (self, **settings)
14 self.googlemap_api_key=googlemap_api_key
15 self.latitude=latitude
16 self.longitude=longitude
19 def template_file (self):
20 return "googlemap.html"
22 def template_env (self, request):
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"
31 # let users configure their googlemap API key in production deployements
32 'js_files' : [ googlemap_api_url,
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",
39 'css_files' : [ "css/googlemap.css",
44 # the list of things passed to the js plugin
45 def json_settings_list (self):
46 return [ 'plugin_uuid', 'query_uuid',
48 'latitude', 'longitude', 'zoom',