can pass starting lat/lon/zoom to googlemap
[unfold.git] / plugins / googlemap / googlemap.js
index 2ab99da..326bf92 100644 (file)
@@ -1,12 +1,11 @@
 /**
- * MySlice GoogleMap plugin
- * URL: http://trac.myslice.info
  * Description: display a query result in a googlemap
- * Author: The MySlice Team
  * Copyright (c) 2012 UPMC Sorbonne Universite - INRIA
  * License: GPLv3
  */
 
+// xxx TODO -- this one could use a bit of cleaning like what was done for the first plugins
+// especially wrt using 'instance' and 'data' in such a confusing way
 
 (function( jQuery ){
 
             $this.data('markerCluster', null);
             $this.data('markers', []);
 
-            var myLatlng = new google.maps.LatLng(34.397, 150.644);
+            console.log ("lat=" + options.latitude + " long=" + options.longitude + " and zoom=" + options.zoom);
+            var myLatlng = new google.maps.LatLng(options.latitude, options.longitude);
             var myOptions = {
-              zoom: 2,
+              zoom: options.zoom,
               center: myLatlng,
               mapTypeId: google.maps.MapTypeId.ROADMAP
             }
            instance_.closest('.need-spin').spin(false);
 
 
-            if (!rows) {
-                alert('error');
+            if (rows === undefined || !rows || rows.length==0) {
+               messages.warning ("Empty result in googlemap.update_map - nothing to show");
                 return;
             }