X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fgooglemap%2Fstatic%2Fjs%2Fgooglemap.js;h=3d1875717376d16164437374d7b9f445fa9a46ee;hb=dfa0e7671a6c8363cc0531bace287d638bc1d510;hp=5f640b93478c36e0a3bb2cb099582e33c3dac30b;hpb=b2353a7fcdfe325432913d5a81fb85619d4d0b25;p=myslice.git diff --git a/plugins/googlemap/static/js/googlemap.js b/plugins/googlemap/static/js/googlemap.js index 5f640b93..3d187571 100644 --- a/plugins/googlemap/static/js/googlemap.js +++ b/plugins/googlemap/static/js/googlemap.js @@ -138,7 +138,7 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; */ create_record_checkbox: function (record, ul, checked) { - var key, key_value; + var key, key_value, data; var checkbox = $("", {type:'checkbox', checked:checked, class:'geo'}); var id = record[this.canonical_key]; @@ -170,7 +170,13 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; */ var self=this; checkbox.change( function (e) { - manifold.raise_event (self.options.query_uuid, this.checked ? SET_ADD : SET_REMOVED, id); + 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; }, @@ -275,6 +281,29 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; }); marker.setVisible(visible); }); + + this.do_clustering(); + }, + + do_clustering: function() + { + this.markerCluster = new MarkerClusterer(this.map, this.markers, {zoomOnClick: false}); + this.markerCluster.setIgnoreHidden(true); + google.maps.event.addListener(this.markerCluster, "clusterclick", function (cluster) { + var cluster_markers = cluster.getMarkers(); + var bounds = new google.maps.LatLngBounds(); + $.each(cluster_markers, function(i, marker){ + bounds.extend(marker.getPosition()); + }); + //map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); + this.map.fitBounds(bounds); + }); + //now fit the map to the bounds + this.map.fitBounds(this.bounds); + // Fix the zoom of fitBounds function, it's too close when there is only 1 marker + if (this.markers.length==1) { + this.map.setZoom(this.map.getZoom()-4); + } }, redraw_map: function() @@ -296,22 +325,8 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; self.markers.push(s.marker); }); - this.markerCluster = new MarkerClusterer(this.map, this.markers, {zoomOnClick: false}); - google.maps.event.addListener(this.markerCluster, "clusterclick", function (cluster) { - var cluster_markers = cluster.getMarkers(); - var bounds = new google.maps.LatLngBounds(); - $.each(cluster_markers, function(i, marker){ - bounds.extend(marker.getPosition()); - }); - //map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); - this.map.fitBounds(bounds); - }); - //now fit the map to the bounds - this.map.fitBounds(this.bounds); - // Fix the zoom of fitBounds function, it's too close when there is only 1 marker - if (this.markers.length==1) { - this.map.setZoom(this.map.getZoom()-4); - } + this.do_clustering(); + /* Set checkbox and background color */ $.each(record_keys, function(i, record_key) { @@ -372,16 +387,34 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; on_field_state_changed: function(data) { - switch(data.request) { - case FIELD_REQUEST_ADD: - case FIELD_REQUEST_ADD_RESET: - this.set_checkbox_from_data(data.value, true); + switch(data.state) { + case STATE_SET: + switch(data.value) { + case STATE_SET_IN: + case STATE_SET_IN_SUCCESS: + case STATE_SET_OUT_FAILURE: + this.set_checkbox_from_data(data.key, true); + this.set_bgcolor(data.key, QUERYTABLE_BGCOLOR_RESET); + break; + case STATE_SET_OUT: + case STATE_SET_OUT_SUCCESS: + case STATE_SET_IN_FAILURE: + this.set_checkbox_from_data(data.key, false); + this.set_bgcolor(data.key, QUERYTABLE_BGCOLOR_RESET); + break; + case STATE_SET_IN_PENDING: + this.set_checkbox_from_data(data.key, true); + this.set_bgcolor(data.key, QUERYTABLE_BGCOLOR_ADDED); + break; + case STATE_SET_OUT_PENDING: + this.set_checkbox_from_data(data.key, false); + this.set_bgcolor(data.key, QUERYTABLE_BGCOLOR_REMOVED); + break; + } break; - case FIELD_REQUEST_REMOVE: - case FIELD_REQUEST_REMOVE_RESET: - this.set_checkbox_from_data(data.value, false); - break; - default: + + case STATE_WARNINGS: + //this.change_status(data.key, data.value); break; } },