[OpenLayers-Users] Click event for 4 maps
Rahn Hanno (rahn)
rahn at zhaw.ch
Wed Apr 7 10:50:32 EDT 2010
Hello list,
In my project I have 4 maps at one side.
In this maps I show polygon. In each map is the same boundaries but in dieffernt timestamps. First map shows a layer in 1980, second map shows the map in 1990, third in 2000 and last in 2010.
In each year the layer is colored different.
Now I try to realise a click event on the maps. I will get some feature info.
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.trigger
}, this.handlerOptions
);
},
trigger: function(e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy);
var bfsCode = bfsNum(lonlat.lon,lonlat.lat,jahr,indikator1);
var aggregat = aggregatNr(bfsCode,vis);
getHighlightLayer(vis,bfsCode,aggregat);
newLoad(lonlat.lon,lonlat.lat,jahr,indikator1,"nodeListL",vis);
// ein-/ausblenden des Infokastens
if (nodeListL.style.display == "none") {
toggleMe('nodeListL');
}
}
});
In the trigger I first get the coordinates (var lonlat) and then I made a query to the Postgres Database (newload(...)).
But of course this only work for the first map, because of the different coordinates. (map.getLonLatFromViewPort)
Here I must use the coordinates from the different maps but I don't know how I can realise this. Is there a possibility to get the map in this function? I need the coordinates from the map where I have clicked.
Can somebody help me? I only want to get the infos from the database with the click. Perhaps there is another usefull workflow to get this featureinfos?
I use UMN Mapserver and OpenLayers 2.8. The Database is PostGIS 8. The Layer is used as a WMS Layer.
var wms = new OpenLayers.Layer.WMS("Gemeinden",urlArray, {map:mapFile,layers:layerName+",Seen",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
This layer will be styled differently for each year with sld and the "mergeNewParams"-Function.
Perhaps somebody can help me, please. I have no idea.
Greetings
Hanno Rahn
------------------------------------------
Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik
ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen
Fachstelle Geoinformatik
Grüental, Postfach CH-8820 Wädenswil
Tel +41 (0)58 934 5592
Fax +41 (0)58 934 5580
hanno.rahn at zhaw.ch
www.iunr.zhaw.ch/geoinformatik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100407/06ab9b56/attachment.html
More information about the Users
mailing list