updated maps
[unfold.git] / plugins / googlemap / __init__.py
index bce84f5..8005de2 100644 (file)
@@ -2,15 +2,16 @@ from unfold.plugin import Plugin
 
 class GoogleMap (Plugin):
 
-    # set checkboxes if a final column with checkboxes is desired
-    # pass columns as the initial set of columns
-    #   if None then this is taken from the query's fields
+    # expcted input are
+    # query :           query about the slice 
+    # query_all :       query about all resources
+    # googlemap_key :   mandatory googlemap API v3 key
     # latitude,longitude, zoom : the starting point
-    def __init__ (self, query, query_all = None, latitude=43., longitude=7., zoom=4, **settings):
+    # apparently at some point there has been support for a boolean 'checkboxes' input arg but seems dropped
+    def __init__ (self, query, googlemap_api_key=None, latitude=50., longitude=50, zoom=3, **settings):
         Plugin.__init__ (self, **settings)
         self.query=query
-        self.query_all = query_all
-        self.query_all_uuid = query_all.query_uuid if query_all else None
+        self.googlemap_api_key=googlemap_api_key
         self.latitude=latitude
         self.longitude=longitude
         self.zoom=zoom
@@ -23,12 +24,16 @@ class GoogleMap (Plugin):
         return env
 
     def requirements (self):
+        googlemap_api_url = "https://maps.googleapis.com/maps/api/js?"
+        if self.googlemap_api_key: googlemap_api_url+="key=%s&"%self.googlemap_api_key
+        googlemap_api_url += "sensor=false"
         reqs = {
-            'js_files' : [ "https://maps.googleapis.com/maps/api/js?sensor=false", 
+            # let users configure their googlemap API key in production deployements
+            'js_files' : [ googlemap_api_url,
                            "/js/googlemap.js",
                            "/js/markerclusterer.js",
                             "js/manifold.js", "js/manifold-query.js", 
-                            "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js", 
+                            "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", 
                             "js/unfold-helper.js",
                            ],
             'css_files' : [ "css/googlemap.css",
@@ -37,4 +42,8 @@ class GoogleMap (Plugin):
         return reqs
 
     # the list of things passed to the js plugin
-    def json_settings_list (self): return ['plugin_uuid','query_uuid', 'query_all_uuid', 'latitude', 'longitude', 'zoom', ]
+    def json_settings_list (self): 
+        return [ 'plugin_uuid', 'query_uuid',
+                 'init_key',
+                 'latitude', 'longitude', 'zoom', 
+                 ]