Created
October 12, 2012 01:51
-
-
Save rjmackay/3876904 to your computer and use it in GitHub Desktop.
Ushahidi JS Diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/themes/default/views/main/main_js.php b/themes/default/views/main/main_js.php | |
index 3254b58..05c479f 100644 | |
--- a/themes/default/views/main/main_js.php | |
+++ b/themes/default/views/main/main_js.php | |
@@ -210,7 +210,7 @@ jQuery(function() { | |
name: "<?php echo Kohana::lang('ui_main.reports'); ?>", | |
url: reportsURL, | |
transform: false | |
- }, true); | |
+ }, true, true); | |
// Register the referesh timeline function as a callback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/media/js/ushahidi.js b/media/js/ushahidi.js | |
index e84823e..08f4ce0 100644 | |
--- a/media/js/ushahidi.js | |
+++ b/media/js/ushahidi.js | |
@@ -296,8 +296,11 @@ | |
* mapControls - {Array(OpenLayers.Control)} The list of controls to add to the map | |
*/ | |
Ushahidi.Map = function(div, config) { | |
- // Internal registry for the maker layers | |
+ // Internal registry for the marker layers | |
this._registry = []; | |
+ | |
+ // Internal list of layers to keep at the top | |
+ this._onTop = []; | |
// Markers are not yet loaded on the map | |
this._isLoaded = 0; | |
@@ -326,7 +329,10 @@ | |
"baselayerchanged", | |
// Map center changed | |
- "mapcenterchanged" | |
+ "mapcenterchanged", | |
+ | |
+ // When a layer is added | |
+ "addlayer" | |
]; | |
// The set of filters/parameters to pass to the URL that fetches | |
@@ -393,6 +399,8 @@ | |
scope: this | |
}; | |
} | |
+ | |
+ mapOptions.eventListeners.addlayer = this.triggerAddLayer; | |
// Check for the controls to add to the map | |
if (config.mapControls == undefined) { | |
@@ -436,6 +444,7 @@ | |
this.register("deletelayer", this.deleteLayer, this); | |
this.register("baselayerchanged", this.updateBaseLayer, this); | |
this.register("mapcenterchanged", this.updateMapCenter, this); | |
+ this.register("addlayer", this.keepOnTop, this); | |
// Pre-load the background image for the popup so that it is | |
// fetched from the cache when when popup is displayed | |
@@ -471,7 +480,7 @@ | |
* parameter should be set to true, if the layer being added is new so as to ensure | |
* that it is redrawn when the map is zoomed in/out or the report filters are updated | |
*/ | |
- Ushahidi.Map.prototype.addLayer = function(layerType, options, save) { | |
+ Ushahidi.Map.prototype.addLayer = function(layerType, options, save, keepOnTop) { | |
// Default markers layer | |
if (layerType == Ushahidi.DEFAULT) { | |
this.deleteLayer("default"); | |
@@ -547,6 +556,11 @@ | |
this._registry.push({layerType: layerType, options: options}); | |
} | |
+ // Save the layer data in the internal registry | |
+ if (keepOnTop !== undefined && keepOnTop) { | |
+ this._onTop.push(options.name); | |
+ } | |
+ | |
// Transform feature geometry to Spherical Mercator | |
preFeatureInsert = function(feature) { | |
if (feature.geometry) { | |
@@ -1143,4 +1157,30 @@ | |
} | |
} | |
+ /** | |
+ * APIMethod: triggerAddLayer | |
+ * Callback that triggers the "addlayer" event. This method | |
+ * is called by OpenLayers when a layer is added | |
+ */ | |
+ Ushahidi.Map.prototype.triggerAddLayer = function(e) { | |
+ if (this._isLoaded) { | |
+ this.trigger("addlayer", e.layer); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * APIMethod: keepOnTop | |
+ * Forces specified layer to the top of the stack | |
+ */ | |
+ Ushahidi.Map.prototype.keepOnTop = function(layer) { | |
+ for (var i=0; i<this._onTop.length; i++) { | |
+ var layerName = this._onTop[i]; | |
+ var layers = this._olMap.getLayersByName(layerName); | |
+ | |
+ for (var j=0; j<layers.length; j++) { | |
+ this._olMap.raiseLayer(layers[j], this._olMap.getNumLayers()); | |
+ } | |
+ } | |
+ } | |
+ | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment