r114515 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114514‎ | r114515 | r114516 >
Date:11:53, 27 March 2012
Author:netbrain
Status:deferred
Tags:
Comment:
fixed a couple of js quirks
Modified paths:
  • /trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js
@@ -122,7 +122,7 @@
123123 }
124124
125125 var line = new OpenLayers.Geometry.LineString(pos);
126 - var lineFeature = new OpenLayers.Feature.Vector(line, null, style);
 126+ var lineFeature = new OpenLayers.Feature.Vector(line, {text:properties.text,title:properties.title}, style);
127127 this.lineLayer.addFeatures([lineFeature]);
128128 }
129129
@@ -180,15 +180,58 @@
181181 this.map = new OpenLayers.Map( mapElementId, mapOptions );
182182 var map = this.map;
183183 this.addControls( map, options.controls, this.get( 0 ) );
184 -
 184+
185185 // Add the base layers.
186186 for ( i = 0, n = options.layers.length; i < n; i++ ) {
187187 map.addLayer( eval( options.layers[i] ) );
188188 }
189189
 190+ //Add markers
190191 this.addMarkers( map, options );
191192 var centre = false;
192 -
 193+
 194+ //Add line layer if applicable
 195+ if(options.lines && options.lines.length > 0){
 196+ this.lineLayer = new OpenLayers.Layer.Vector("Line Layer");
 197+ this.lineLayer.events.on({
 198+ 'featureselected':function(feature){
 199+ if(feature.feature.attributes.text != undefined && feature.feature.attributes.text != ''){
 200+ var mousePos = map.getControlsByClass("OpenLayers.Control.MousePosition")[0].lastXy
 201+ var lonlat = map.getLonLatFromPixel(mousePos);
 202+ var popup = new OpenLayers.Popup(null,lonlat, null, feature.feature.attributes.text, true,function(){
 203+ map.getControlsByClass('OpenLayers.Control.SelectFeature')[0].unselectAll();
 204+ map.removePopup(this);
 205+ })
 206+ this.map.addPopup( popup );
 207+ }
 208+ },
 209+ 'featureunselected':function(feature){
 210+ //do nothing
 211+ }
 212+ });
 213+
 214+ var controls = {
 215+ select: new OpenLayers.Control.SelectFeature(this.lineLayer,{
 216+ clickout: true, toggle: false,
 217+ multiple: true, hover: false
 218+ })
 219+ };
 220+
 221+ for(key in controls){
 222+ var control = controls[key];
 223+ map.addControl(control);
 224+ control.activate();
 225+ }
 226+
 227+ map.addLayer(this.lineLayer);
 228+ map.raiseLayer(this.lineLayer,-1);
 229+ map.resetLayersZIndex();
 230+
 231+ for ( var i = 0; i < options.lines.length; i++ ) {
 232+ this.addLine(options.lines[i]);
 233+ }
 234+ }
 235+
193236 if ( options.centre === false ) {
194237 if ( options.locations.length == 1 ) {
195238 centre = new OpenLayers.LonLat( options.locations[0].lon, options.locations[0].lat );
@@ -219,16 +262,6 @@
220263 } );
221264 }
222265
223 - if(options.lines){
224 - this.lineLayer = new OpenLayers.Layer.Vector("Line Layer");
225 - map.addLayer(this.lineLayer);
226 - map.addControl(new OpenLayers.Control.DrawFeature(this.lineLayer, OpenLayers.Handler.Path));
227 -
228 - for ( var i = 0; i < options.lines.length; i++ ) {
229 - this.addLine(options.lines[i]);
230 - }
231 - }
232 -
233266 if(options.copycoords){
234267 map.div.oncontextmenu = function(){return false;};
235268 OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {

Status & tagging log