- return {marker:marker, ul:ul};
- },
-
- // given an input <ul> element, this method inserts a <li> with embedded checkbox
- // for displaying/selecting the resource corresponding to the input record
- // returns the created <input> element for further checkbox manipulation
- create_record_checkbox: function (record,ul,checked) {
- var checkbox = $("<input>", {type:'checkbox', checked:checked, class:'geo'});
- var id=this.record_id(record);
- // use hrn as far as possible for displaying
- var label= ('hrn' in record) ? record.hrn : id;
- ul.append($("<li>").addClass("geo").append(checkbox).
- append($("<span>").addClass("geo").append(label)));
- var googlemap=this;
- // the callback for when a user clicks
- // NOTE: this will *not* be called for changes done by program
- checkbox.change( function (e) {
- manifold.raise_event (googlemap.options.query_uuid, this.checked ? SET_ADD : SET_REMOVED, id);
- });
- return checkbox;
- },
-
- warning: function (record,message) {
- try {messages.warning (message+" -- hostname="+record.hostname); }
- catch (err) {messages.warning (message); }
- },
-
- // retrieve DOM checkbox and make sure it is checked/unchecked
- set_checkbox: function(record, checked) {
- var id=this.record_id (record);
- if (! id) {
- this.warning (record, "googlemap.set_checkbox: record has no id");
- return;
- }
- var checkbox = this.by_id [ id ];
- if (! checkbox ) {
- this.warning (record, "googlemap.set_checkbox: checkbox not found");
- return;
- }
- checkbox.prop('checked',checked);
- }, // set_checkbox
-
- // this record is *in* the slice
- new_record: function(record) {
- if (googlemap_debug_detailed) messages.debug ("new_record");
- if (!(record['latitude'])) return false;
-
- // get the coordinates
- var latitude=unfold.get_value(record['latitude']);
- var longitude=unfold.get_value(record['longitude']);
+ //extend the bounds to include each marker's position
+ this.bounds.extend(marker.position);
+ return { marker: marker, ul: ul };
+ },
+
+ /* given an input <ul> element, this method inserts a <li> with embedded checkbox
+ * for displaying/selecting the resource corresponding to the input record
+ * returns the created <input> element for further checkbox manipulation
+ */
+ create_record_checkbox: function (record, ul, checked)
+ {
+ var key, key_value, data;
+
+ var checkbox = $("<input>", {type:'checkbox', checked:checked, class:'geo'});
+ var id = record[this.canonical_key];
+ var init_id = record[this.init_key];
+
+ // xxx use init_key to find out label - or should we explicitly accept an incoming label_key ?
+ var label = init_id;
+
+ key = this.canonical_key;
+ key_value = manifold.record_get_value(record, key);
+
+ ul.append($("<li>").addClass("geo")
+ .append($('<div>') // .addId(this.id_from_key(key, key_value))
+ .append(checkbox)
+ .append($("<span>").addClass("geo")
+ .append(label)
+ )
+ )
+ );
+
+ // XXX STATE / BACKGROUND
+
+ // hash by id and by init_id
+ this.by_id[id]=checkbox;
+ this.by_init_id[init_id] = checkbox;
+
+ /* the callback for when a user clicks
+ * NOTE: this will *not* be called for changes done by program
+ */
+ var self=this;
+ checkbox.change( function (e) {
+ data = {
+ state: STATE_SET,
+ key : null,
+ op : this.checked ? STATE_SET_ADD : STATE_SET_REMOVE,
+ value: id
+ }
+ manifold.raise_event(self.options.query_uuid, FIELD_STATE_CHANGED, data);
+ });
+ return checkbox;
+ },
+
+ set_checkbox_from_record_key: function (record_key, checked)
+ {
+ if (checked === undefined) checked = true;
+
+ var checkbox = this.by_init_id [record_key];
+ if (!checkbox) {
+ console.log("googlemap.set_checkbox_from_record - not found " + record_key);
+ return;
+ }
+
+ checkbox.attr('checked', checked);
+ },
+
+
+ set_checkbox_from_data: function(id, checked)
+ {
+ var checkbox = this.by_id[id];
+ if (!checkbox) {
+ console.log("googlemap.set_checkbox_from_data - id not found " + id);
+ return;
+ }
+ checkbox.attr('checked', checked);
+ },
+
+ set_bgcolor: function(key_value, class_name)
+ {
+ var elt = $(document.getElementById(this.id_from_key(this.canonical_key, key_value)))
+ if (class_name == GOOGLEMAP_BGCOLOR_RESET)
+ elt.removeClass('added removed');
+ else
+ elt.addClass((class_name == GOOGLEMAP_BGCOLOR_ADDED ? 'added' : 'removed'));
+ },
+
+
+ /**
+ * Populates both this.by_lat_lon and this.arm_marker arrays
+ */
+ new_record: function(record)
+ {
+ var record_key;
+
+ if (!(record['latitude']))
+ return;
+
+ /* get the coordinates*/
+ var latitude = unfold.get_value(record['latitude']);
+ var longitude = unfold.get_value(record['longitude']);