this.in_set_backlog = [];
// we keep a couple of global hashes
- // lat_lon --> { marker, <ul> }
- // id --> { <li>, <input> }
- this.by_lat_lon = {};
- this.by_id = {};
+ // lat_lon --> { marker, <ul> }
+ // hrn --> { <li>, <input> }
+ this.by_lat_lon = {};
+ this.by_hrn = {};
/* XXX Events */
this.elmt().on('show', this, this.on_show);
this.object = query.object;
var keys = manifold.metadata.get_key(this.object);
- //
+ //
this.key = (keys && keys.length == 1) ? keys[0] : null;
+ // xxx temporary hack
+ // as of nov. 28 2013 we have here this.key='urn', but in any place where
+ // the code tries to access record[this.key] the records only have
+ // keys=type,hrn,network_hrn,hostname
+ // so for now we force using hrn instead
+ // as soon as record have their primary key set this line can be removed
+ // see also same hack in querytable
+ this.key= (this.key == 'urn') ? 'hrn' : this.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 */
/* PLUGIN EVENTS */
on_show: function(e) {
- if (googlemap_debug) messages.debug("googlemap.on_show");
+ if (googlemap_debug) messages.debug("googlemap.on_show");
var googlemap = e.data;
google.maps.event.trigger(googlemap.map, 'resize');
}, // on_show
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);
+ if (googlemap_debug) messages.debug("gmap.initialize_map based on domid=" + domid + " elmt=" + elmt);
this.map = new google.maps.Map(elmt, myOptions);
this.infowindow = new google.maps.InfoWindow();
}, // initialize_map
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
+ // gmap can deal with a DOM element but not a jquery object
content: dom.get(0),
});
return {marker:marker, ul:ul};
checkbox.prop('checked',checked);
}, // set_checkbox
- // this record is *in* the slice
+ // this record is *in* the slice
new_record: function(record) {
- if (googlemap_debug_detailed) messages.debug ("new_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']);
}, // new_record
arm_marker: function(marker, map) {
- if (googlemap_debug_detailed) messages.debug ("arm_marker content="+marker.content);
+ if (googlemap_debug_detailed) messages.debug ("arm_marker content="+marker.content);
var googlemap = this;
google.maps.event.addListener(marker, 'click', function () {
googlemap.infowindow.close();
/*************************** RECORD HANDLER ***************************/
on_new_record: function(record) {
- if (googlemap_debug_detailed) messages.debug("on_new_record");
+ if (googlemap_debug_detailed) messages.debug("on_new_record");
if (this.received_all)
// update checkbox for record
this.set_checkbox(record, true);
},
on_clear_records: function(record) {
- if (googlemap_debug_detailed) messages.debug("on_clear_records");
+ if (googlemap_debug_detailed) messages.debug("on_clear_records");
},
// Could be the default in parent
on_query_in_progress: function() {
- if (googlemap_debug) messages.debug("on_query_in_progress (spinning)");
+ if (googlemap_debug) messages.debug("on_query_in_progress (spinning)");
this.spin();
},
on_query_done: function() {
- if (googlemap_debug) messages.debug("on_query_done");
+ if (googlemap_debug) messages.debug("on_query_done");
if (this.received_all) {
this.unspin();
- }
+ }
this.received_set = true;
},
on_field_state_changed: function(data) {
- if (googlemap_debug_detailed) messages.debug("on_field_state_changed");
+ if (googlemap_debug_detailed) messages.debug("on_field_state_changed");
switch(data.request) {
- case FIELD_REQUEST_ADD:
- case FIELD_REQUEST_ADD_RESET:
- this.set_checkbox(data.value, true);
- break;
- case FIELD_REQUEST_REMOVE:
- case FIELD_REQUEST_REMOVE_RESET:
- this.set_checkbox(data.value, false);
- break;
- default:
- break;
+ case FIELD_REQUEST_ADD:
+ case FIELD_REQUEST_ADD_RESET:
+ this.set_checkbox(data.value, true);
+ break;
+ case FIELD_REQUEST_REMOVE:
+ case FIELD_REQUEST_REMOVE_RESET:
+ this.set_checkbox(data.value, false);
+ break;
+ default:
+ break;
}
},
// all : this
on_all_new_record: function(record) {
- if (googlemap_debug_detailed) messages.debug("on_all_new_record");
+ if (googlemap_debug_detailed) messages.debug("on_all_new_record");
this.new_record(record);
},
on_all_clear_records: function() {
- if (googlemap_debug) messages.debug("on_all_clear_records");
+ if (googlemap_debug) messages.debug("on_all_clear_records");
},
on_all_query_in_progress: function() {
- if (googlemap_debug) messages.debug("on_all_query_in_progress (spinning)");
+ if (googlemap_debug) messages.debug("on_all_query_in_progress (spinning)");
// XXX parent
this.spin();
},
on_all_query_done: function() {
- if (googlemap_debug) messages.debug("on_all_query_done");
+ if (googlemap_debug) messages.debug("on_all_query_done");
// MarkerClusterer
var markers = [];
$.each(this.in_set_backlog, function(i, record) {
googlemap.set_checkbox(record, true);
});
- // reset
- googlemap.in_set_backlog = [];
+ // reset
+ googlemap.in_set_backlog = [];
- if (googlemap_debug) messages.debug("unspinning");
+ if (googlemap_debug) messages.debug("unspinning");
this.unspin();
}
this.received_all = true;