-
- // we cannot directly edit html, since nothing but marker is displayed
- //var checkbox_id = this.id('checkbox', this.id_from_key(this.key, key_value));
- //checkbox_id = '#' + checkbox_id.replace(/\./g, '\\.');
- //$(checkbox_id, this.table.fnGetNodes()).attr('checked', checked);
-
- var dict_info = this.map_markers[unfold.escape_id(key_value).replace(/\\/g, '')];
-
-
- // Update the marker content
- dict_info.in_set = checked;
- dict_info.marker.content = this.get_marker_content(dict_info.record, checked);
-
- // Thierry - this code seems to cause the googlemap area to go all grayed out
- // once all the quesries have come back
- // BEG turning off temporarily
- // // Update opened infowindow
- // // XXX Factor this code
- // this.infowindow.close();
- // this.infowindow.open(this.map, dict_info.marker);
- // this.infowindow.setContent(dict_info.marker.content);
- // this.elts('map-button').unbind('click').click(this, this._button_click);
- // END turning off temporarily
- //var button = this.checkbox(record, checked);
- //this.elmt('checkbox', this.id_from_record(method, record)).html(button);
- },
-
- checkbox: function(record, checked) {
- if (googlemap_debug_detailed) messages.debug ("checkbox");
- if (typeof checked === 'undefined')
- checked = false;
-
- var method = manifold.query_store.find_analyzed_query(this.options.query_uuid).object;
- var action = checked ? 'checked' : 'del';
- var ctx = {
- action_class : checked ? 'ui-icon-circle-minus' : 'ui-icon-circle-plus',
- action_message: checked ? 'Remove from slice' : 'Add to slice',
- };
- var button = this.load_template('template', ctx);
-
- var id_record = this.id_from_record(method, record);
- if (!id_record)
- return 'ERROR';
- var id = this.id('checkbox', this.id_from_record(method, record));
- return "<div id='" + id + "'>" + button + "</div>";
- },
-
- get_marker_content: function(record, checked) {
- if (googlemap_debug_detailed) messages.debug ("get_marker_content");
- return '<p><b>' + this.method + '</b>: ' + get_value(record['resource_hrn']) + '<br/><b>network</b>: ' + get_value(record['network'])+'</p>' + this.checkbox(record, checked);
- },
-
- /**
- */
+ // 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
+ // resources_selected was getting all mixed up
+ // hazelnut does publish hrn's with backslashes and that seems like the thing to do
+ return key_value;
+ },
+
+ // return { marker: gmap_marker, ul : <ul DOM> }
+ create_marker_struct: function (object,lat,lon) {
+ // the DOM fragment
+ var dom = $("<p>").addClass("geo").append(object+"(s)");
+ var ul = $("<ul>").addClass("geo");
+ dom.append(ul);
+ // add a gmap marker to the mix
+ var marker = new google.maps.Marker({
+ position: new google.maps.LatLng(lat, lon),
+ title: object,
+ // gmap can deal with a DOM element but not a jquery object
+ content: dom.get(0),
+ });
+ return {marker:marker, ul:ul};
+ },
+
+ // add an entry in the marker <ul> tag for that record
+ // returns { checkbox : <input DOM> }
+ create_record_checkbox: function (record,ul,checked) {
+ var checkbox = $("<input>", {type:'checkbox', checked:checked, class:'geo'});
+ var hrn=this.record_hrn(record);
+ ul.append($("<li>").addClass("geo").append(checkbox).
+ append($("<span>").addClass("geo").append(hrn)));
+ 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) {
+ if (googlemap_debug) messages.debug("googlemap click handler checked= " + this.checked + " hrn=" + hrn);
+ manifold.raise_event (googlemap.options.query_uuid,
+ this.checked ? SET_ADD : SET_REMOVED, hrn);
+ });
+ return checkbox;
+ },
+
+ // retrieve DOM checkbox and make sure it is checked/unchecked
+ set_checkbox: function(record, checked) {
+ var hrn=this.record_hrn (record);
+ if (! hrn) { messages.warning ("googlemap.set_checkbox: record has no hrn"); return; }
+ var checkbox_s = this.by_hrn [ hrn ];
+ if (! checkbox_s ) { messages.warning ("googlemap.set_checkbox: could not spot checkbox for hrn "+hrn); return; }
+ checkbox_s.checkbox.prop('checked',checked);
+ }, // set_checkbox
+
+ // this record is *in* the slice