Index: C:/src/java/express/express.company.ee/WebContent/common/javascript/mapstraction/mapstraction.js =================================================================== --- C:/src/java/express/express.company.ee/WebContent/common/javascript/mapstraction/mapstraction.js (revision 231) +++ C:/src/java/express/express.company.ee/WebContent/common/javascript/mapstraction/mapstraction.js (working copy) @@ -336,6 +336,37 @@ } break; case 'openlayers': + OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { + defaultHandlerOptions: { + 'single': true, + 'double': false, + 'pixelTolerance': 0, + 'stopSingle': false, + 'stopDouble': false + }, + + initialize: function(options) { + this.handlerOptions = OpenLayers.Util.extend( + {}, this.defaultHandlerOptions + ); + OpenLayers.Control.prototype.initialize.apply( + this, arguments + ); + this.handler = new OpenLayers.Handler.Click( + this, { + 'click': this.onClick + }, this.handlerOptions + ); + }, + + onClick: function(e) { + var lonlat = me.maps[api].getLonLatFromViewPortPx(e.xy); + var point = new LatLonPoint(lonlat.lat,lonlat.lon); + point.fromOpenLayers(); + me.clickHandler(point.lat,point.lon,me); + } + + }); this.maps[api] = new OpenLayers.Map( element.id, @@ -344,7 +375,11 @@ maxResolution:156543, numZoomLevels:18, units:'meters', projection: "EPSG:41001" } ); - + for (var i = this.maps[api].controls.length; i>1; i--) { + this.maps[api].controls[i-1].deactivate(); + this.maps[api].removeControl(this.maps[api].controls[i-1]); + } + this.layers['osmmapnik'] = new OpenLayers.Layer.TMS( 'OSM Mapnik', [ @@ -406,9 +441,14 @@ displayOutsideMaxExtent: true } ); - + this.maps[api].addLayer(this.layers['osmmapnik']); this.maps[api].addLayer(this.layers['osm']); + + var click = new OpenLayers.Control.Click(); + this.maps[api].addControl(click); + click.activate(); + this.loaded[api] = true; break; case 'openstreetmap': @@ -976,10 +1016,6 @@ case 'openlayers': // FIXME: OpenLayers has a bug removing all the controls says crschmidt - for (var i = map.controls.length; i>1; i--) { - map.controls[i-1].deactivate(); - map.removeControl(map.controls[i-1]); - } // FIXME - can pan & zoom be separate? if ( args.pan ) { map.addControl(new OpenLayers.Control.PanZoomBar()); } else { }