+ this.by_id = {};
+ this.by_init_id = {};
+
+ /* Events */
+ // xx somehow non of these triggers at all for now
this.elmt().on('show', this, this.on_show);
- // TODO in destructor
- // $(window).unbind('QueryTable');
+ this.elmt().on('shown.bs.tab', this, this.on_show);
+ this.elmt().on('resize', this, this.on_resize);
var query = manifold.query_store.find_analyzed_query(this.options.query_uuid);
this.object = query.object;
- var keys = manifold.metadata.get_key(this.object);
- //
- this.key = (keys && keys.length == 1) ? keys[0] : null;
+ // see querytable.js for an explanation
+ var keys = manifold.metadata.get_key(this.object);
+ this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
+ //
+ this.init_key = this.options.init_key;
+ // have init_key default to canonical_key
+ this.init_key = this.init_key || this.canonical_key;
+ // sanity check
+ if ( ! this.init_key ) messages.warning ("QueryTable : cannot find init_key");
+ if ( ! this.canonical_key ) messages.warning ("QueryTable : cannot find canonical_key");
+ if (debug) messages.debug("googlemap: canonical_key="+this.canonical_key+" init_key="+this.init_key);
//// Setup query and record handlers
- // this query is the one about the slice itself
- // event related to this query will trigger callbacks like on_new_record
+ // this query is the one about the slice itself
+ // event related to this query will trigger callbacks like on_new_record
this.listen_query(options.query_uuid);
- // this one is the complete list of resources
- // and will be bound to callbacks like on_all_new_record
+ // this one is the complete list of resources
+ // and will be bound to callbacks like on_all_new_record
this.listen_query(options.query_all_uuid, 'all');
/* GUI setup and event binding */
@@ -59,10 +76,14 @@ googlemap_debug_detailed=false;
/* PLUGIN EVENTS */
on_show: function(e) {
- if (googlemap_debug) messages.debug("googlemap.on_show");
+ if (debug) messages.debug("googlemap.on_show");
var googlemap = e.data;
google.maps.event.trigger(googlemap.map, 'resize');
- }, // on_show
+ },
+ // dummy to see if this triggers at all
+ on_resize: function(e) {
+ if (debug) messages.debug("googlemap.on_resize ...");
+ },
/* GUI EVENTS */
@@ -70,137 +91,112 @@ googlemap_debug_detailed=false;
initialize_map: function() {
this.markerCluster = null;
-
+ //create empty LatLngBounds object in order to automatically center the map on the displayed objects
+ this.bounds = new google.maps.LatLngBounds();
var center = new google.maps.LatLng(this.options.latitude, this.options.longitude);
var myOptions = {
zoom: this.options.zoom,
center: center,
- scrollwheel: false,
+ scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
-
+
var domid = this.options.plugin_uuid + '--' + 'googlemap';
- var elmt = document.getElementById(domid);
- if (googlemap_debug) messages.debug("gmap.initialize_map based on domid=" + domid + " elmt=" + elmt);
+ var elmt = document.getElementById(domid);
this.map = new google.maps.Map(elmt, myOptions);
this.infowindow = new google.maps.InfoWindow();
}, // initialize_map
- // xxx probably not the right place
- // The function accepts both records and their key
- record_hrn : function (record) {
- var key_value;
- switch (manifold.get_type(record)) {
- case TYPE_VALUE:
- key_value = record;
- break;
- case TYPE_RECORD:
- if ( ! this.key in record ) return;
- key_value = record[this.key];
- break;
- default:
- throw "Not implemented";
- break;
- }
- // XXX BACKSLASHES original code was reading like this
- //return this.escape_id(key_value).replace(/\\/g, '');
- // however this sequence removes backslashes from hrn's and as a result
- // queryupdater was getting all mixed up
- // querytable does publish hrn's with backslashes and that seems like the thing to do
- return key_value;
- },
-
- // return { marker: gmap_marker, ul :