[OpenLayers-Users] Conversion of BBox for GetFeature Request
Jerome A. Wendell
jawendell at digitalmapping.com
Wed Mar 6 17:26:41 PST 2013
The problem must be in the events.register because it does not even get to the point of logging the feature that was added.
Thanks.
From: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Jerome A. Wendell
Sent: Wednesday, March 06, 2013 4:54 PM
To: 'Gery .'
Cc: 'OpenLayers User List'
Subject: Re: [OpenLayers-Users] Conversion of BBox for GetFeature Request
Gery,
Thanks for your quick reply. I will give your suggestion a try, and see what happens.
Thanks again for all of your help.
Jerome
From: Gery . [mailto:gamejihou at hotmail.com]
Sent: Wednesday, March 06, 2013 4:48 PM
To: <jawendell at digitalmapping.com>
Cc: OpenLayers User List
Subject: Re: [OpenLayers-Users] Conversion of BBox for GetFeature Request
Hi Jerome,
Not sure here, but seems to me that the problem is the events.register, try this to see what is going on there:
myControl.events.register("featureselected", this, function(e) {
highlightLayer.addFeatures(e.features);
console.log("THIS HAS BEEN ADDED: " + e.features);
});
myControl.events.register("featureunselected", this, function(e) {
highlightLayer.removeFeatures(e.features);
console.log("THIS HAS BEEN DELETED: " + e.features);
Try some variants inside the parentheses of each console.log call.
Sent from my iBath
On Mar 6, 2013, at 22:38, "Jerome A. Wendell" <jawendell at digitalmapping.com> wrote:
I was having a difficult time getting the code to work for a box selection, so I decided to set it up for selection on click. The click selection actually works better for my particular situation. The control is now returning features, but there seems to be a problem with adding them to the highlight layer. The code that I am using is below:
var highlightLayer = new OpenLayers.Layer.Vector("Highlighted Features", {
styleMap: myStyles,
displayInLayerSwitcher: false,
isBaseLayer: false
}
);
OpenLayers.Control.myGetFeature = OpenLayers.Class(OpenLayers.Control.GetFeature,{
selectClick: function(evt){
var layerSRSgeo = new OpenLayers.Projection('EPSG:4326');
var baseSRSmer = new OpenLayers.Projection('EPSG:900913');
var bounds = this.pixelToBounds(evt.xy).transform(baseSRSmer,layerSRSgeo);
this.request(bounds, {single: this.single});
},
CLASS_NAME: 'OpenLayers.Control.myGetFeature'
});
var myControl = new OpenLayers.Control.myGetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(mylayer),
box: false,
hover: false,
maxFeatures: 40,
clickTolerance: 1
});
myControl.events.register("featureselected", this, function(e) {
highlightLayer.addFeatures(e.features);
});
myControl.events.register("featureunselected", this, function(e) {
highlightLayer.removeFeatures(e.features);
});
map.addControl(myControl);
myControl.activate();
The error that I now get is below:
<image001.png>
I have been working on troubleshooting this issue for quite a while and have been searching for an answer. So far I have been unsuccessful in getting the selected features added to the highlight layer.
Any suggestions that you might have are greatly appreciated.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130306/6e12857b/attachment-0001.html>
More information about the Users
mailing list