AW: [OpenLayers-Users] pick an attribute from a wms layer when I draw
a point in another vector layer
Arnd Wippermann
arnd.wippermann at web.de
Tue Dec 6 17:24:31 EST 2011
Hi,
register featureadded for your vector layer:
yourLayer.events.register("featureadded", yourLayer, function (e){
comunePickFunc(e)
/*
var lon = e.feature.geometry.x;
var lat = e.feature.geometry.y;
var w = 5*map.resolution;
BBOX = (lon-w) + "," + (lat-w) + "," + (lon+w) + "," + (lat+w);
window.open("someServer&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&QUE
RY_LAYERS=[layers]&LAYERS=[layers]&BBOX=" + BBOX +
"&SRS=EPSG:31466&X=50&Y=50&WIDTH=100&HEIGHT=100&FORMAT=image/png&INFO_FORMAT
=text/html&FEATURE_COUNT=1&STYLES=");
*/
});
Arnd
_____
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von beppe
Gesendet: Dienstag, 6. Dezember 2011 17:03
An: users at openlayers.org
Betreff: [OpenLayers-Users] pick an attribute from a wms layer when I draw a
point in another vector layer
Hi all,
I've a function "A"[0] for picking an attribute from a wms layer, the value
is passed to a form.
I've another function "B"[1] for draw and save a point in a postgis table
(via geoserver), this function is triggered when I click the form "save"
button.
Function A works fine except when I want to insert a new point.
I want the function A to be triggered when drawing a point on the map...but
I don't know how!
Some suggestion?
thanks a lot
-beppe-
[0]
function comunePickFunc(e) {
if (e.features && e.features.length) {
var nomeComune = e.features[0].attributes.nome;
var id = e.features[0].attributes.id;
document.getElementById('comune').innerHTML = nomeComune;
$('#id_comune').val(id);
$.ajax({
type: "POST",
url: "inc/dinSelComune.php",
data: {id:id},
cache: false,
success: function(html){$("#indirizzo").html(html);}
});//ajax
}
}
var comunePick = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/wms',
title: 'identify features on click',
layers: [comuni],
queryVisible: true
});
comunePick.infoFormat = 'application/vnd.ogc.gml';
comunePick.events.register("getfeatureinfo", this, comunePickFunc);
map.addControl(comunePick);
comunePick.activate();
[1]
function salvaSito(fid){
var fid = OpenLayers.Util.getElement('fid').value;
var feature = siti.getFeatureById(fid);
feature.attributes.comune = OpenLayers.Util.getElement('comune').value;
feature.attributes.indirizzo =
OpenLayers.Util.getElement('indirizzo').value;
feature.attributes.data = OpenLayers.Util.getElement('data').value;
onFeatureUnselect(feature);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111206/8f2e865a/attachment-0001.html
More information about the Users
mailing list