Index: trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | } |
124 | 124 | |
125 | 125 | 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); |
127 | 127 | this.lineLayer.addFeatures([lineFeature]); |
128 | 128 | } |
129 | 129 | |
— | — | @@ -180,15 +180,58 @@ |
181 | 181 | this.map = new OpenLayers.Map( mapElementId, mapOptions ); |
182 | 182 | var map = this.map; |
183 | 183 | this.addControls( map, options.controls, this.get( 0 ) ); |
184 | | - |
| 184 | + |
185 | 185 | // Add the base layers. |
186 | 186 | for ( i = 0, n = options.layers.length; i < n; i++ ) { |
187 | 187 | map.addLayer( eval( options.layers[i] ) ); |
188 | 188 | } |
189 | 189 | |
| 190 | + //Add markers |
190 | 191 | this.addMarkers( map, options ); |
191 | 192 | 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 | + |
193 | 236 | if ( options.centre === false ) { |
194 | 237 | if ( options.locations.length == 1 ) { |
195 | 238 | centre = new OpenLayers.LonLat( options.locations[0].lon, options.locations[0].lat ); |
— | — | @@ -219,16 +262,6 @@ |
220 | 263 | } ); |
221 | 264 | } |
222 | 265 | |
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 | | - |
233 | 266 | if(options.copycoords){ |
234 | 267 | map.div.oncontextmenu = function(){return false;}; |
235 | 268 | OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { |